I have a set of nested models for storing prices for individual rooms.
Ie.
Places
Rooms
Room_rates
Each model has the necessary accepts_nested_attributes_for and has_many belongs_to association and I have a form and a build method which works perfectly for the initial creation.
My question is how to make a smarter contro...
I have dynamic form which has a set of values. I created a partial which contains text fields which I display. Next to each of them I would like to display a label containing the title of the text. For instance First Name, and Last Name would not be known previously. How do I go about doing that?
It seems that I cannot access the attribu...
I have a many-to-many relationship with a link box, and I want to pull those models together into one form so I can update from the same page. I'm really struggling with getting the check_box to even show all the elements of my array - I've scoured the net and been working on this literally all day, and I'm finding it difficult to apply ...
Hi,
I have a simple model
class Ad < ActiveRecord::Base
has_many :ad_items
end
class AdItem < ActiveRecord::Base
belongs_to :ad
end
I have an "ads/new" view, that shows me the form for creating the new ad and adding some items to it
The .html.erb code is like a following:
<% form_for @ad, do |ad_form| %>
<!-- some html -->...
I am building a Rails application which allows a user to create an object that refers to multiple other models, creating them if they do not exist, and just associating to ones that already exist:
# app/models/upload.rb
class Upload < AR:B
belongs_to :user
belongs_to :observed_property
belongs_to :sensor
accepts_nested_attribut...
I have this models
class Store < ActiveRecord::Base
has_many :person , :class_name =>"person"
accepts_nested_attributes_for :person
end
class Person < ActiveRecord::Base
has_many :addresses,
:as => :addressable,
:dependent => :destroy,
:validate => false
accepts_nested_attributes_for :addresses
...
My goal is to enable a user to be able to submit multiple NewsImages from a parent Blog form.
My Blog model looks like this:
# == Schema Information
# Schema version: 20091006171847
#
# Table name: blogs
#
# id :integer(4) not null, primary key
# title :string(255)
# body :text
# profile_id :inte...
I have such code in new.erb.html:
<% form_for(@ratification) do |f| %>
<%= f.error_messages %>
<% f.fields_for :user do |fhr| %>
<p>
<%= fhr.label :url %><br />
<%= fhr.text_field_with_auto_complete :url %>
</p>
<% end %>
<% end %>
If i have empty Ratification.rb it is ok, fields_for works ok.
But if I wr...
So I have read & re-read the Stephen Chu article on the topic (http://www.stephenchu.com/2008/05/rails-composedof-validation.html), however I am just not having any luck.
Per the example on provided in the money gem documentation money.rubyforge .org
Model
class Payment < ActiveRecord::Base
composed_of :amount,
:class_name => "M...
Hi folks,
I'm trying to created a set of nested (many-to-many) forms in rails 3. Everything works fine thanks to fields_for, but I need to put a title above each nested form. That title has the value of the profession_type.name field (which has a prepopulated value) in each respective nested form.
I'm having a heckuva time extracting t...
Hi folks,
I'm trying to add a fields_for attribute to a nested rails form. Any time I try to create a new object, it returns
Message(#58819400) expected, got
Array(#18903800) ...
app/controllers/discussions_controller.rb:53:in
`create'
If I try to access nested fields_for from forms based on non-nested resources (aka "for...
i have a form_for code
<%form_for :a,:url=>{:controller=>"biz/a",:action=>"save"},:html =>{:multipart => true} do |f| %>
.....
<%f.fields_for :b do |b|%>
.....
<%b.fields_for :apples do |apple|%>
...
<%end%>
....
<%end%>
it outputs the html code without fields_for function
<textarea cols="40" id="a_b_apples_content" name="a[b][appl...