I have 3 particles that have forms inside them. I am calling these particles on my edit view page. I am getting an error saying "undefined local variable or method `f'" I am trying to define f, but I believe I am confused as to what syntax and convention to use. I believe I am close but I am a little mixed up.
views/ideas/edit.html.erb
<%= render :partial => "ideas_nav" %>
<h1><%= @idea.working_name %></h1>
<div id="idea_show_container">
<%= form_for @idea do |f| %>
<div id="basic_details" class="idea-show-columns">
<%= render :partial => 'idea_basic_edit', @ideas => {:f => f} %>
<%= render :partial => 'comments', @ideas => {:f => f} %>
<%= render :partial => 'mockups', @ideas => {:f => f} %>
</div>
<% if current_user.has_copywriter_access? %>
<div id="copy_details" class="idea-show-columns">
<%= render :partial => 'copy_edit', @ideas => {:f => f} %>
</div>
<% end %>
<% if current_user.has_artist_access? %>
<div id="art_details" class="idea-show-columns ">
<%= render :partial => 'art_edit', @ideas => {:f => f} %>
</div>
<% end %>
</div>
<%= f.submit %>
<%end%>
one of the particles _idea_basic_edit.erb:
<fieldset data-model="idea-basic" class="idea-edit">
<h2>Basic Idea Specs</h2>
<div data-attribute="product_sku" class="edit-field">
<%= label :sku, "Product SKU" %>
<%= f.text_field :sku %>
</div>
<div data-attribute="working_name" class="edit-field">
<%= label :working_name, "Working Name" %>
<%= f.text_field :working_name %>
</div>
<div data-attribute="priority" class="edit-field">
<%= f.label :priority, 'Priority Level' %>
<%= f.select :priority, Idea::PRIORITIES.collect{ |level, label| [label, level]} %>
</div>
<% if current_user.has_overlord_access? %>
<div data-attribute="overlord_id" class="edit-field">
<%= f.label :overlord_id, 'Sign Off' %>
<%= f.select :overlord_id, User.overlords.collect{|o| [o.full_name, o.id]},
:include_blank => true %>
</div>
<% end %>
<br data-clear="all" />
<div data-attribute="working_description" class="edit-field">
<%= label :working_description, "Working Description" %>
<%= f.text_area :working_description %>
</div>
</fieldset>
idea controller configs:
def edit
@idea = Idea.find_by_permalink(params[:id])
end
def update
@idea = Idea.find_by_permalink(params[:id])
if request.xhr?
if params[:comment]
@idea.comments.create(:title => params[:comment][:title], :comment => params[:comment]
[:comment], :user_id => current_user.id)
end
if @idea.update_attributes(update_status_params)
@success = true
else
@success = false
end
else
if @idea.update_attributes(edit_idea_params)
flash[:notice] = 'Idea updated!'
redirect_to idea_url(params[:id])
else
render :edit
end
end
end
def edit_idea_params
(params[:idea][:color_ids] ||= []) unless !current_user.has_artist_access?
(params[:idea][:imprintable_ids] ||= []) unless !current_user.has_copywriter_access?
(params[:idea][:stores_ids] ||= []) unless !current_user.has_copywriter_access?
(params[:idea][:taxonomies_ids] ||= []) unless !current_user.has_copywriter_access?
params.require(:idea).permit(:sku, :working_name, :working_description, :priority,
:product_name, :product_line_tokens,
:description, :meta_description, :meta_keywords, :artist_id,
:copywriter_id, :overlord_id,
{:store_ids => []}, {:taxonomy_ids => []}, :base_price,
:shipping_category, :default_artwork_id,
:tax_category, {:imprintable_ids => []}, :marketplace,
:product_type,
:base, :colors_offered, :special_instructions, :copy_status,
:art_status, {:color_ids => []},
:artworks_attributes => [:height, :width, :from_top,
:from_center, :idea_id, :dimensions, :file, :_destroy, :id])
end
log:
Started PATCH "/ideas/bpul_dishes" for 127.0.0.1 at 2013-11-07 13:07:29 -0500
ActiveRecord::SchemaMigration Load (0.2ms) SELECT `schema_migrations`.* FROM
`schema_migrations`
Processing by IdeasController#update as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"FTWlXzQpJYQBE4fCV2z9jZddpx3Epf5ZBecOEfax4eA=", "idea"=>{"sku"=>"
bpul_dishe", "working_name"=>"DO ME (DIRTY DISHES)", "priority"=>"5", "overlord_id"=>"",
"working_description"=>"\"Hey, Ann Arbor T-shirt Company - you know what we want? A sexy
dishwashing shirt\", said the people. And lo, the Ann Arbor T-shirt Company did deliver.",
"copy_status"=>"Awaiting Approval", "copywriter_id"=>"", "product_name"=>"DO ME (DIRTY
DISHES)", "description"=>"\"Hey, Ann Arbor T-shirt Company - you know what we want? A sexy
dishwashing shirt\", said the people. And lo, the Ann Arbor T-shirt Company did deliver.",
"base_price"=>"15.0", "meta_description"=>"Funny Bar, Party, Pick-up Line T-shirt",
"meta_keywords"=>"bar crawl shirt, adult humor shirt, inneuendo shirt, bad taste shirt,
dirty joke shirt", "product_line_tokens"=>"1", "store_ids"=>["", "102", "15"],
"taxonomy_ids"=>[""], "product_type"=>"T-shirt", "shipping_category"=>"T-shirt",
"tax_category"=>"Taxable", "marketplace"=>"1", "art_status"=>"Awaiting Approval",
"artist_id"=>"4",
"default_artwork_id"=>"343", "color_ids"=>["", "14"], "base"=>"0",
"special_instructions"=>"",
"artworks_attributes"=>{"0"=>{"dimensions"=>"10x12", "width"=>"9.4", "height"=>"8.5",
"from_top"=>"1.0", "from_center"=>"0.0", "_destroy"=>"0", "id"=>"342"}, "1"=>
{"dimensions"=>"14x16", "width"=>"12.9", "height"=>"11.6", "from_top"=>"1.0",
"from_center"=>"0.0", "_destroy"=>"0", "id"=>"343"}}}, "commit"=>"Update Idea",
"id"=>"bpul_dishes"}
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 6 ORDER BY
`users`.`id` ASC LIMIT 1
Idea Load (0.4ms) SELECT `ideas`.* FROM `ideas` WHERE `ideas`.`deleted` = 0 AND
`ideas`.`permalink` = 'bpul_dishes' ORDER BY `ideas`.`created_at` DESC LIMIT 1
Role Load (0.4ms) SELECT DISTINCT `roles`.* FROM `roles` INNER JOIN `users_roles` ON
`roles`.`id` = `users_roles`.`role_id` WHERE `users_roles`.`user_id` = 6 ORDER BY name
asc,
`roles`.name ASC
Unpermitted parameters: stores_ids, taxonomies_ids