Skip to content

Instantly share code, notes, and snippets.

@crova
Created June 12, 2016 20:48
Show Gist options
  • Save crova/4b139440b9118bba2e163f4774fcfbbb to your computer and use it in GitHub Desktop.
Save crova/4b139440b9118bba2e163f4774fcfbbb to your computer and use it in GitHub Desktop.
Having trouble with strong params and update action
<table summary="Shoot form fields">
<tr>
<th><%= f.label('campaign_id', "Campaign ID") %></th>
<td><%= @single_shoot.id %></td>
<td><%= f.hidden_field :id, :value => @single_shoot.id %></td>
</tr>
<tr>
<th><%= f.label(:name, "Name") %></th>
<td><%= f.text_field(:name) %></td>
</tr>
<tr>
<th><%= f.label(:payout) %></th>
<td><%= f.text_field(:payout) %></td>
</tr>
<tr>
<th><%= f.label(:result) %></th>
<td><%= f.text_field(:result) %></td>
</tr>
<tr>
<th><%= f.label(:segment) %></th>
<td><%= f.select(:segment, options_for_select([['Ativos', 'Ativos'], ['Inativos', 'Inativos']])) %></td>
</tr>
<tr>
<th><%= f.label(:deal) %></th>
<td><%= f.select(:deal, options_for_select([['CPL', 'CPL'], ['CPC', 'CPC'], ['CPM', 'CPM'], ['CTL', 'CTL'], ['CPA', 'CPA']])) %></td>
</tr>
<tr>
<th><%= f.label(:partner) %></th>
<td><%= f.select(:partner, options_for_select([['Actual Sales', 'Actual Sales'], ['Adlead', 'Adlead'], ['DGMax', 'DGMax'], ['MDS Perf', 'MDS Perf'], ['Keep Media', 'Keep Media']])) %></td>
</tr>
</table>
<% @page_title = "Edit Shoot" %>
<%= link_to("<< Back to List", {:action => 'index'}, :class => 'back-link') %>
<div class="shoots edit">
<h2>Update Shoot</h2>
<%= debug params %>
<%= form_for(:campaign, :url => {:action => 'update'}, method: "post","id" => @single_shoot.id) do |f| %>
<%= render(:partial => "form", :locals => {:f => f}) %>
<div class="form-buttons">
<%= submit_tag("Update Page") %>
</div>
<% end %>
</div>
ActionController::ParameterMissing in CampaignController#update
param is missing or the value is empty: id
Extracted source (around line #63):
61
62
63
64
65
66
private
def single_shoot_params
params.require(:id).permit(:payout, :result, :name, :segment, :deal, :partner)
end
def update
@single_shoot = Campaign.find_by_id(params[:id])
if @single_shoot.update_attributes(single_shoot_params)
flash[:notice] = "Shoot updated successfully."
redirect_to(:action => 'show', :id => @single_shoot.id)
else
render('edit')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment