I have a projects resource that has many tasks. I want to ensure that every task has a project_id by adding validates_presence_of :project_id to the tasks model.
However, when creating a new project with tasks, the project_id won't be available until the record saves, therefore I can't use validates_presence_of :project_id.
So my que...
I am using rails3 beta3 and couchdb via couchrest. I am not using active record.
I want to add multiple "Sections" to a "Guide" and add and remove sections dynamically via a little javascript. I have looked at all the screencasts by Ryan Bates and they have helped immensely. The only difference is that I want to save all the section...
I'm getting this exception when doing a nested model form:
ActiveRecord::AssociationTypeMismatch in RecipesController#update
Ingredient(#35624480) expected, got Ingredient(#34767560)
The models involved are Recipe and Ingredient. Recipe has_many and accepts_nested_attributes_for :ingredients, which belongs_to :recipe.
I get this e...
Hi all i'm getting this error when I try to post a comment on a post.
The error
Cannot redirect to nil!
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1104:in `redirect_to'
/Users/Mister/dev/blog/app/controllers/comments_controller.rb:9
Comments/Controller:
class CommentsController < ApplicationCon...
I'm trying to build a simple product backlog application to teach myself Rails. For each product, there can be multiple product backlog entries, so I want to create a product view that shows the product information, all the backlog entries for the product, and includes a nested form for adding more backlog entries.
Everything works unti...
I am using rails 3.0.0.beta3 and I am trying to implement form with nested attributes using :accepts_nested_attributes_for.
My form is nested to three levels: Survey >> Question >> Answer.
Survey has_many Questions, and Question has many Answers.
Inside the Survey model, there is
:accepts_nested_attributes_for :questions
and inside...
so i am trying to save to a join table in a habtm relationship, but i am having problems.
from my view, i pass in a group id with:
= link_to "Create New User", new_user_url(:group => 1)
User model (user.rb)
class User < ActiveRecord::Base
has_and_belongs_to_many :user_groups
accepts_nested_attributes_for
:user_groups end
...
I have a ad banner that has a form and this is used by 3rd party site owners that grab this code and have this banner on there site.
Since some sites that use this banner have a <form> wrapping there entire site i have found that the banners form doesn't submit it rather submits the outer form.
Here is the code:
<form onSubmit="retu...
I'm trying to implement Ryan's Railscast #197 in a system with Questions, Answers, and (multiple choice) Options. http://railscasts.com/episodes/197-nested-model-form-part-2.
I have successfully implemented the nesting among these forms/partials.
The simpler 'check box' way to delete records works properly.
The problem occurs when I tr...
Hey guys, I've been beating my head against a wall with a particular use case for nested forms (I'm using Rails 2.3.5).
Essentially I have Project and Payment models that looks like this
class Project < ActiveRecord::Base
has_many :payments
end
class Payment < ActiveRecord::Base
belongs_to :project
accepts_nested_attributes_for ...
I'm trying to manually build form fields for a testing purpose. I got the following models:
class Bedroom < ActiveRecord::Base
has_many :booked_bedrooms
has_many :bookings, :through => :booked_bedrooms
end
class Booking < ActiveRecord::Base
has_many :booked_bedrooms
has_many :bedrooms, :through => :booked_bedrooms
a...
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...
PROBLEM
I have a nested PHP array that I need to populate from flat scalar
values. The problem is I cannot know ahead of time what the structure
of the nested PHP array will be until I get the request to fill in
the flat scalar values.
EXAMPLE
// example where we populate the array using standard PHP
$person['contact_info']['fname']...
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...
Hello !
I'm trying to use this example but it doesn't work.
I guess it's because I use a shallow nested model !
I get this error : Template is missing
Missing template pprojects/create with {:formats=>[:html], :handlers=>[:builder, :erb, :haml, :rjs, :rhtml, :rxml], :locale=>[:en, :en]}
It looks like my app is trying to do HTML and no ...
Hi all,
I'm having trouble getting my InventoryItem to accept nested attributes which is strange.
In my script/console, I did the following:
>> InventoryItem.create!(:name => 'what', :image_attributes => [ {:image => File.open("/home/davidc/Desktop/letterbx.jpg", "r") }])
ActiveRecord::UnknownAttributeError: unknown attribute: image_a...
Im trying to update some nested params from a form. I can see that the parameters im getting from the form is correct, however the database dont get updated.
the view
<% form_for @order do |f| %>
<% f.fields_for :itemgroups do |ff, i| %>
<% ff.fields_for :items do |fff| %>
<%= ff.text_field :text, :id => "textField", :disab...
I have a page that uses Ryan Bates nested_form plugin. The plugin is used when you have form based on one model and then additional fields that belong to another model. For example if I had a form that created categories, and at the same time I wanted to add items to the new category, my form would contain input fields for the category m...
Hi, I'd like to generate a form with nested object forms like this (in haml):
- form_for @parent do |parent_form|
- parent_form.fields_for :children do |child_form|
= child_form.label :first_name
= child_form.text_field :first_name
... and I'd like to place the child forms in a jquery ui (1.8.2) accordion, like this (I think...
Ive created a nested model form the RailsCasts Nested Model Form Part 2 example and have it working with Rails 3 and JQuery. Currently, a user can create a new project and click a link to add new tasks, and within each new task, click a link that will allow them to add new assignments to each task. Here's the link to create a new task ...