Displaying 20 results from an estimated 10000 matches similar to: "undefined method when redering form (rails 2.3)"
2009 Jul 01
2
Nested Forms - how to displayed the attributes content ?
I have a User model
class User < ActiveRecord::Base
has_one :account
accepts_nested_attributes_for :account, :allow_destroy => true
validates_associated :account
attr_accessible :account_attributes
is working fine, validating and updating both records (User and
Account), but I caanot display the value in the form when is updated,
ex: below the firstname is not displayed but
2011 Mar 02
2
Nested forms validation problem
Hi All,
I''m trying to learn Ruby on Rails and have got an issue with the
validation of a nested form. I think I have got it setup correctly as it
appears to be saving the data as expected, but it is not wrapping the
CSS class (field_with_errors) to the fields, and if data is entered into
the nested fields it disappears on form submit (if there are validation
errors). The validation
2006 Aug 11
2
Accessing belongs_to objects from a form_for context
In a form_for context, is there a way to access objects that are related
to the primary object with a belongs_to? I think an example will serve
best:
class User < ActiveRecord::Base
belongs_to :person
attr_accessor :username
end
class Person < ActiveRecord::Base
has_one :user
attr_accessor :first_name
end
<% form_for :user do |form| %>
<%= form.text_field
2009 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the
console, but not from the view. I have the following:
# partial schema
create_table "users", :force => true do |t|
t.string "login", :null => false
t.string "first_name"
t.string "last_name"
t.string "email", :null => false
2013 Sep 30
0
TypeError: no implicit conversion of Symbol into Hash when submitting form to upload files
I''m currently new to Rails and Ruby and I''m trying to learn from my
mistakes, this time I''m trying to upload 2 files from a form for later
processing, however, after I hit the "Submit" button. I keep getting this
error:
TypeError in UploadFilesController#create
app/controllers/upload_files_controller.rb:28:in `new''
2010 Apr 06
1
captcha in a belongs_to
Hi
I am using simple_captcha. I have two models User and Staff.
Relation ship are
User has_one staff
staff belongs_to user
Now in the staff edit I have to include a captcha. I did like
<% form_for @user, :url => staff_url(@staff), :html => {:method => :put
} do |f|%>
<p>
<%= f.text_field :first_name,:maxlength => 50 %>
</p>
2006 May 26
1
Form for Multiple Models
I have a signup form that needs to do these three things:
1) create a new "Group"
2) create a new "User"
3) Add that User to the Group
I have the scaffolding for the create new user form:
<% form_for :user do |form| %>
<p>
<label for="user_name">First Name:</label>
<%= form.text_field
2010 Feb 10
2
undefined method 'state'
I can''t imagine what I''m trying to do is complicated at all in Rails.
Yet, I am now getting this error: undefined method `state'' for
:StudentFailState:Symbol.
student.rb
has_one :student_fail
attr_accessor :student_fail_attribute
#controller
def student_fail
@student = @student.find params[:id]
def update_student_fail
@student.build_student_fail
2006 Jul 11
0
Arbitrary elements in form_for?
I would like to use form_for in my project so that I can easily change
the style of many forms at once. However, it seems to me like
FormBuilders only support certain kinds of form elements(!). Surely
there must be a way to add arbitrary labels/form elements to a form.
Let''s say I had a form that looks like:
ID: (plain-text label)
Name: (text field)
Birthdate: (date chooser)
Picture:
2010 Dec 23
0
has_many :through full stack help
I am trying to implement HMT for the first time and having a ton of
trouble. I would like to be able to have the user check a checkbox
and fill some extra fields for data input. I have tried so many
iterations borrowed from different places I found on the web, none
seem to work quite right. Essentially I have two models: ''practice''
and ''system'' where a
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in
the browser.
<h1>New member</h1>
<%= error_messages_for :member %>
<% form_for(:member, :url => members_path) do |f| %>
<fieldset>
<legend>Member Info</legend>
<p><label for="member[first_name]">First Name:</label> <%=
2006 Jun 23
3
form_remote_tag is not passing form params
I''ve searched and searched and searched again, and I cannot find any
help with this problem. There''s an identical problem on this forum, but
it was never resolved. I''ll try to re-open the subject with a bit more
information.
Problem: The form_remote_tag() method in my "list" view is not passing
the params[] hash of the values stored within my form.
2006 Sep 27
5
Question about has_one
I have a question about regarding the use of ''has_one'' in this scenario:
Schema:
User
----
id
first_name
last_name
UserMessage
----
user_id
message_id
Message
----
id
Assuming business rules dictate that a Message can have at most ONE User
(let''s assume a message can be created without a user associated to it),
these are my questions:
1) How would I use has_one
2010 May 05
0
Auto_complete with has_one association
Hi,
Have an issue with the rails auto complete, it works fine but I don''t
know how to find the id element search in the textfield.
Here is what I''ve done:
<%= text_field_with_auto_complete :user, :ville_name, { :size => 15 },
{ :url => formatted_villes_path(:js), :method => :get, :param_name =>
''search'' } %>
Model:
class User <
2009 Jul 07
1
Adding data in two tables simul;taneously with Validations
Hi All,
I have 2 tables
1] user_infos &
2] users
class UserInfo
has_one :user
validates_presence_of :city
class User
belongs_to :user_info
validates_presence_of :first_name
i write following code in my create method.
@user_info = UserInfo.new(params[:user_info])
@user=@user_info.build_user(:first_name=>'''')
if @user_info.save
else
end
now what i want is to
2005 Dec 11
1
redering CDATA wierdness
I am attempting to do the sortable_element tutorial from scriptaculous.
(http://demo.script.aculo.us/ajax/sortable_elements)
Upon viewing the script.aculo.us source, I see this line is generated...
<script type="text/javascript">Sortable.create(''list'',
{onUpdate:function(){new Ajax.Updater(''list-info'', ''/ajax/order'',
2007 Dec 07
4
capitalizing an attribute - view, controller, or model?
The users will enter students names on forms. How do I intercept the
first and last names and have them stored capitalized when the user
inputs them in lower case?
Do I mess with the form html, skipping form_for helpers and using
conditional clauses in the view?
Do I need to separate out the individual attribute and update it
separately in the controller actions that save/updates the
2010 Oct 15
1
Help with nested form: User and Artist
Artist is 1:1 with User. User has_one :artist
In my artist model, I have:
belongs_to :user
accepts_nested_attributes_for :user
However, in my artist _form, the name column from the user model does
not display. I am doing:
<% f.fields_for :user do |builder| %>
<p class="fields">
<%= builder.label :name %>
<%= builder.text_field :name %>
2009 Jun 20
0
[Rails 2.3] nested_attributes and validation of nested model
Hi,
I''m using nested models to create form in my view. It looks like this:
<% form_for :user, :url => {:action => "add_owner" }, :html => {
:method => :post } do |u| %>
<li><label>Name: </label><%= u.text_field :name %></li>
<li><label>Surname: </label><%= u.text_field :surname %></li>
<%
2006 Sep 21
3
:order by association field
Hi. I''m trying to do something that should be a fairly common pattern,
but I''m currently not sure how.
BACKGROUND:
model Family has_one Father. also, Family has field "country_of_origin"
model Father has a number of fields, such as first_name, age, etc.
It''s easy to sort based on families'' fields:
sorted_families = Family.find(:all, :order =>