Tagged Questions
0
votes
1answer
49 views
Implementing a model of a model in rails
I am just starting out with rails and have run into a little issue. What I am trying to implement is a way to allow users to create "pages" on which they can tack on widgets.
So I have set up a ...
0
votes
2answers
26 views
Validating a blank field Rails Model
This may be somewhat basic but cannot find a definitive answer anywhere. I have set up a contact form within my app and have put in a hidden field that when completed disables the submit button with ...
0
votes
1answer
32 views
Rails: How to retrieve an attribute from a related model?
I seem to be stuck with a problem that probably should be more obvious to me: How can I get certain attributes from a related model to show in a view.
In my application there are these 2 models:
...
0
votes
2answers
28 views
Custom Validations Rails Model
I have a contact form and would like to show individual messages depending on what has failed.I would like to use flash messages. So from what i have read so far i can create a custom method (or i ...
0
votes
1answer
21 views
NoMethodError at /orders/new undefined method `validate_on_create'
I am currently getting a NoMethodError at /orders/new
undefined method 'validate_on_create' for #<Class:0x000000047fde70>. My code seems to be simple and should be functional but it is not.
...
1
vote
0answers
45 views
How to check if relationship model's fields are empty?
I have a user and user details models that are in has-one <-> belong-to relationship. Initially, when the user is registered (created) his details are not populated.
I want when the user log in, ...
0
votes
0answers
31 views
Re-save model AND associated models Rails Console
I have 3 models:
class User < ActiveRecord::Base
has_one :student_registration
has_one :user_lookup
end
class StudentRegistration < ActiveRecord::Base
belongs_to :user
end
class ...
1
vote
0answers
31 views
how to pass the value to custom foreign key and make the foreign key appears its value in the second form
how can to pass the value to a custom foreign key (ward_id) and how to make the admission number which will be inserted in student form , appears in the second form parent/guardian detals > ward_id , ...
0
votes
0answers
38 views
How to get the player with the highest score with SQL
here is the setup of my problem.
class Match < ActiveRecord::Base
attr_accessible :acceptor, :a_id, :c_id, :game, :game_id, :wager
belongs_to :game
has_many :scores
scope :matches_won_by, lambda ...
0
votes
1answer
27 views
Rendering model errors like JSON in js template
I am submitting form with data-remote=true attribute. The create action in the controller looks like:
format.js { @user }
and it is handled by the following template:
create.js.erb
Is there an ...
0
votes
1answer
57 views
Model naming convention for Rails
Override Rails controller routing with capital letters in model name
I followed that question and answer, but it did not help me.
I need to create a model from an already existing table, BBOrders.
...
0
votes
0answers
23 views
Model association dependent by type
Let's say we have a Certificate model with a type(:string) attribute. Depending of the type value, Certificate could have only one instance of three Models(VehicleCertificate, HealthCertificate and ...
1
vote
2answers
43 views
Global variable for language_id available in views and in models
I'm trying to share a session variable in both the controllers, the views and the model.
With the following code, it is working in the controllers and in the views :
class ApplicationController < ...
0
votes
1answer
61 views
rails joins models confusion (join many tables)
Here is my three models/tables
class Swimming::Classschedule < ActiveRecord::Base
belongs_to :swimming_classtimes ,:class_name=>'Swimming::Classtime',:foreign_key => "classtime_id"
...
1
vote
0answers
80 views
Find Or Create Rails Nested Attribute By Name
I have a Model called Example that accepts_nested_attributes_for NestedExample.
When I create a new Example Model I can also create NestedExamples:
params = { :name => 'Example 1', ...