similar to: Problem with models and modules.

Displaying 20 results from an estimated 30000 matches similar to: "Problem with models and modules."

2007 Aug 14
2
Finding a models asscoations
Hi, I cant seem to find the answer to this anywhere so any help/advice is appreciated. Each project has one risk and a risk has a number of has/one belongs to assocations. So what i want to do is in my code loop through all the associations for a risk and display some field information from each as they are pretty similar. So somehting like <% for model_association in project.risks %>
2006 Aug 04
4
DRY DRY DRY
Hello everyone! Ive been on rails for the last month or so and really enjoyed this framework. However its very hard to find documentation on how to do things right! For example every beginner after a while realizes that having similar CRUD actions in every controller and views for them is not DRY at all! Few days ago I found http://dereksivers.com/rails-shared-controller.html I quite like his
2006 Jun 17
0
Dynamic forms containing collections
Hiall, I have the following problem: I need to use forms containing collections (i will call them FCC), and I want to construct them dynamically, as I need to deal with quite large forms (more than 600 input fields). The variables @model_name and @field_name contain the proper model and field names as strings, which is enough for "normal" form input fields. (i.e. the "if
2012 Apr 14
7
undefined method `model_name' for NilClass:Class
Hi guys, I just started using Ruby on Rails. After implementing the RoR blog tutorial I started with my own data model. Sadly I am not able to get my create page running. Model: class Activity < ActiveRecord::Base validates :activity, :presence => true validates :forKids, :presence => true validates :start_date, :presence => true end Controller: class ActivitiesController <
2008 May 30
9
find_by_sql without a model? how to do this?
Hi, I''d like to do a "find_by_sql" without a model (e.g. <model name>.find_by_sql("...")) as the results I get back are a once off special, and I''m happy to handle them as an array. How do I do this? "ActiveRecord::Base.find_by_sql(...)" does not seem to work? Background - At the moment I''m doing within a model <model_name>,
2012 Apr 25
2
Rails 3.1 - Scaffolding Files
Where can I find more information about the new syntax on these: <%- model_class = @product.class -%> <h1><%=t ''.title'', :default => t(''helpers.titles.new'', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}") %></h1> <%= render :partial =>
2006 Jan 17
4
find_by_sql column ordering defect?
Hello. I have a program that accesses a metadata (translation) table for column names as well as the ordering of columns for a specific model. Also in there is a collection of bool options such as column_visible_on_form, column_visible_on_screen_quicklist etc. The idea is that our customer can specify to a certain extent how their layout/user interface will appear. To accomplish this, I use
2006 Jun 18
2
using javascript to get an attribute using an ID
Hi everyone, I''m trying to use ajax to update the selected value of a select element. Here''s what I have so far: function RailsModel(model_name) { this.model_name = model_name; } RailsModel.prototype.getAttributeById = function(attribute, id) { Ajax.Request(''/models/get_attribute_by_id/'' + this.model_name + ''/'' + attribute +
2006 Dec 11
1
organizing stats from a list of models
Hi there, I have a list of models (about 600 glm models) and I included the prefix "mod_" on their name. Now I would like retrieve the list from the R environment and save their AICs (and other info) on a table. I´m trying something like: ------------------------- y<-runif(20,min=0,max=1) x1<-runif(20,min=0,max=1) x2<-runif(20,min=0,max=1) mymod_1
2006 Mar 29
0
How to organize models into modules
Being a bit of a neat freek, I would like to organize the models in my Rails app into modules. I have created the directory structure as follows: models |- module1 |- mymodel.rb And my model class code is: module Module1 class Mymodel ...some stuff end end How do I include this model in my controllers without referencing it as "Module1::Mymodel"? Also, how do I
2006 Feb 20
2
file_column: changing default store_dir
File_column plugin is great. I need to change the default :store_dir from the dynamic "model_name/attribute_name" to an equally dynamic "client_id/app_id/model_name/attribute_name". In my model I have: class Component < ActiveRecord::Base belongs_to :component_type belongs_to :component_group breakpoint file_column :content, :magick => { :versions
2007 Mar 19
0
action_web_services error with rspec_on_rails
I now have two specs in my rails project which correspond to one rails controller. I can run them individually and they pass, but running them together (either with the rake task just putting both files on the command line): euclid% spec spec/controllers/crud_resource_controller_spec.rb spec/ controllers/crud_resource_controller_with_join_models_spec.rb
2006 Apr 27
3
collection_select to display 2 fields
I''m trying to get a collection_select generated Drop-down box to display two fields from a table (first name & last name); however, I am having trouble concatenating the symbols. It appears as though any code I put in the 5th argument for collection_select is processed prior to executing the collection_select method. The code executes successfully with 1 symbol in the 5th
2006 Mar 23
6
easy scaffold question(s)
I''m doing very well with the Hibbs Rolling on Rails tutorial. I have an easy question for my personal notes. I''m coming up with a simple framework of steps for creating a basic database. It includes the following maxims to make original app creation easy: app_name = MySQL database name SQL_tablename = model_name model_name = controller-name Is this going to work for getting
2006 Jul 06
1
<model>.update(...) not calling before_update callback.
Hi, I''m doing a <model_name>.update(....) but I''m noticing that my before_update callback is not being called. If I do a find and then a save!, I notice that it is called. The problem with a find and save in my case is that I''m not able to set all my attributes in one shot by saving params["user"] and since I can''t do this, my overloaded
2006 Feb 13
1
dynamically generating a controller and appropriate routing
I''m working on a library similar to acts_as_taggable. I''d like it to be a simple, one file drop-in: i.e., put my_library.rb into RAILSROOT/lib/ and have everything work. However, the library requires a controller to render some stuff, so I need to be able to create the controller class, set the routing, and extend the controller at run-time from within my_library.rb. I have code
2005 Aug 10
1
using modules with models?
I''m trying to figure out how to use modules with my model classes. I''m going to have good number of model classes that don''t map to the database, and I''d like to put some of these in seperate modules. I''ve been wrestling with this for 2 days and can''t figure out how to get it to work. Rails seems to handle it fine for controllers, though. I
2006 Jun 12
0
Realtime form validation for forms containing collections
Hi, I''m successfully using the realtime_form_validation plugin from http://railsrtv.rubyforge.org/ However, my forms contain collections, as described in the AWDWR book. Basically my form looks like this. 2004 2005 2006 Question 1 12 13 15 Question 2 9 11 13 I have the following code to generate ids for my input fields.
2012 Sep 03
0
undefined method `singular_route_key' for "User":ActiveModel::Name
In ActionDispatch::PolymorphicRoutes, there is a call to build_named_route_call an on line 172 (of latest rails code from github), there is a call to singular_route_key: model_name_from_record_or_class(parent).singular_route_key Now model_name_from_record_or_class returns an ActiveModel::Name object, which is a wrapper to the string class, that returns a string name of the class of an
2013 May 20
0
db connection returns stale values
Hello, I''m working on a rails 3 app for a legacy oracle db. I have a controller that saves object graphs (accepts_nested_attributes_for) but I noticed the post-update JSON response still contains the pre-update values. After some debugging, it appears the database connection is returning stale values (find(), reload(), etc., all return pre-update values; but SQL clients and