Hidden_field can't find an Active Record by its idPassing an array into hidden_field RORHow do I use hidden_field in a form_for in Ruby on Rails?declarative_authorization problem with creating new userdynamic nested form always creates an extra blank entry - using formtastic_coocoonCan't find the 'libpq-fe.h header when trying to install pg gemrails - what exactly does hidden_field and hidden_field_tag do?Rails3 hidden_field in hamlPassing hidden_field ids becomes an errorRoute failing using STIhidden_field syntax problems
How do I identify the partitions of my hard drive in order to then shred them all?
What dog breeds survive the apocalypse for generations?
is it correct to say "When it started to rain, I was in the open air."
Why does the headset man not get on the tractor?
How can we allow remote players to effectively interact with a physical tabletop battle-map?
Ansible: use group_vars directly without with_items
Is it safe to use two single-pole breakers for a 240 V circuit?
How about space ziplines
Were any toxic metals used in the International Space Station?
Is this possible when it comes to the relations of P, NP, NP-Hard and NP-Complete?
How to describe a building set which is like LEGO without using the "LEGO" word?
complicated arrows in flowcharts
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
Biology of a Firestarter
Generate ladder of integers using the least number of unique characters (in C++)
The meaning of the Middle English word “king”
Would life always name the light from their sun "white"
Why does SSL Labs now consider CBC suites weak?
Will casting a card from the graveyard with Flashback add a quest counter on Pyromancer Ascension?
Is there any way to adjust the damage type of the Eldritch Blast cantrip so that it does fire damage?
How to continually let my readers know what time it is in my story, in an organic way?
How do I adjust encounters to challenge my lycanthrope players without negating their cool new abilities?
Is Valonqar prophecy unfulfilled?
Why can't I share a one use code with anyone else?
Hidden_field can't find an Active Record by its id
Passing an array into hidden_field RORHow do I use hidden_field in a form_for in Ruby on Rails?declarative_authorization problem with creating new userdynamic nested form always creates an extra blank entry - using formtastic_coocoonCan't find the 'libpq-fe.h header when trying to install pg gemrails - what exactly does hidden_field and hidden_field_tag do?Rails3 hidden_field in hamlPassing hidden_field ids becomes an errorRoute failing using STIhidden_field syntax problems
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to create an new ActiveRecord relationship taking current_user's id and assignment's id as foreign keys with a simple button press by the user. The user would be accepting the assignment and it would create that new association in a record. I already tested the models in the console and accept/decline work correctly as intended.
The error says when I click the button:
ActiveRecord::RecordNotFound in ContractsController#create
The form_for hidden_field doesn't pass assignment.id correctly, the parameter says:
"utf8"=>"✓", "authenticity_token"=>"dkGBIQxS06xiu9GR6+aYLgA6ZArgFD5iipl7HKDCFPdXhDKjX6dSajrLlrwvLlj4IzGutcX1lT51IhM5ksxt4Q==", "assignment_id"=>[""], "commit"=>"Accept"
As you can see, the assignment_id is blank. Not sure if I'm doing it right so, what's the correct way to do this?
I basically copied the code from Michael Hartl's tutorial on making Twitter, the concept is similar to an user following another user. I've already verified that the assignment record exists using find(#) in rails console myself.
_accept.html.erb
<%= form_for(current_user.active_contracts.build, local: true) do |f| %>
<div><%= hidden_field_tag :assignment_id, @assignment.id %></div>
<%= f.submit "Accept", class: "btn btn-primary" %>
<% end %>
ContractController.rb
def create
@assignment = Assignment.find(params[:assignment_id])
current_user.accept(@assignment)
redirect_to @assignment
end
assignment#index
<div class="col-md-9">
<h2><%= assignment.event_title %></h2><br>
<strong>Date: </strong><%= assignment.date_start.strftime("%D") %><br>
<strong>Time: </strong><%= assignment.time_start.strftime("%I:%M %p") %> to <%= assignment.time_end.strftime("%I:%M %p") %><br>
<strong>Address:</strong><br>
<address><%= assignment.addressline1 %><br>
<% if !assignment.addressline2.blank? %>
<%= assignment.addressline2 %><br>
<% end %>
<%= assignment.city %>, <%= assignment.state %> <%= assignment.zip %>
</address>
</div>
<% if assignment.user_id == current_user.id %>
<div class="col-md-3">
<%= link_to "Update", title_assignment_path(assignment), class: "btn btn-primary btn-block" %>
</div>
<% end %>
<% if current_user.ssp? %>
<div class="col-md-3">
<%= render 'accept' %>
</div>
<% end %>
</div>
<% end %>
</div>
ruby-on-rails hidden-field
add a comment |
I'm trying to create an new ActiveRecord relationship taking current_user's id and assignment's id as foreign keys with a simple button press by the user. The user would be accepting the assignment and it would create that new association in a record. I already tested the models in the console and accept/decline work correctly as intended.
The error says when I click the button:
ActiveRecord::RecordNotFound in ContractsController#create
The form_for hidden_field doesn't pass assignment.id correctly, the parameter says:
"utf8"=>"✓", "authenticity_token"=>"dkGBIQxS06xiu9GR6+aYLgA6ZArgFD5iipl7HKDCFPdXhDKjX6dSajrLlrwvLlj4IzGutcX1lT51IhM5ksxt4Q==", "assignment_id"=>[""], "commit"=>"Accept"
As you can see, the assignment_id is blank. Not sure if I'm doing it right so, what's the correct way to do this?
I basically copied the code from Michael Hartl's tutorial on making Twitter, the concept is similar to an user following another user. I've already verified that the assignment record exists using find(#) in rails console myself.
_accept.html.erb
<%= form_for(current_user.active_contracts.build, local: true) do |f| %>
<div><%= hidden_field_tag :assignment_id, @assignment.id %></div>
<%= f.submit "Accept", class: "btn btn-primary" %>
<% end %>
ContractController.rb
def create
@assignment = Assignment.find(params[:assignment_id])
current_user.accept(@assignment)
redirect_to @assignment
end
assignment#index
<div class="col-md-9">
<h2><%= assignment.event_title %></h2><br>
<strong>Date: </strong><%= assignment.date_start.strftime("%D") %><br>
<strong>Time: </strong><%= assignment.time_start.strftime("%I:%M %p") %> to <%= assignment.time_end.strftime("%I:%M %p") %><br>
<strong>Address:</strong><br>
<address><%= assignment.addressline1 %><br>
<% if !assignment.addressline2.blank? %>
<%= assignment.addressline2 %><br>
<% end %>
<%= assignment.city %>, <%= assignment.state %> <%= assignment.zip %>
</address>
</div>
<% if assignment.user_id == current_user.id %>
<div class="col-md-3">
<%= link_to "Update", title_assignment_path(assignment), class: "btn btn-primary btn-block" %>
</div>
<% end %>
<% if current_user.ssp? %>
<div class="col-md-3">
<%= render 'accept' %>
</div>
<% end %>
</div>
<% end %>
</div>
ruby-on-rails hidden-field
add a comment |
I'm trying to create an new ActiveRecord relationship taking current_user's id and assignment's id as foreign keys with a simple button press by the user. The user would be accepting the assignment and it would create that new association in a record. I already tested the models in the console and accept/decline work correctly as intended.
The error says when I click the button:
ActiveRecord::RecordNotFound in ContractsController#create
The form_for hidden_field doesn't pass assignment.id correctly, the parameter says:
"utf8"=>"✓", "authenticity_token"=>"dkGBIQxS06xiu9GR6+aYLgA6ZArgFD5iipl7HKDCFPdXhDKjX6dSajrLlrwvLlj4IzGutcX1lT51IhM5ksxt4Q==", "assignment_id"=>[""], "commit"=>"Accept"
As you can see, the assignment_id is blank. Not sure if I'm doing it right so, what's the correct way to do this?
I basically copied the code from Michael Hartl's tutorial on making Twitter, the concept is similar to an user following another user. I've already verified that the assignment record exists using find(#) in rails console myself.
_accept.html.erb
<%= form_for(current_user.active_contracts.build, local: true) do |f| %>
<div><%= hidden_field_tag :assignment_id, @assignment.id %></div>
<%= f.submit "Accept", class: "btn btn-primary" %>
<% end %>
ContractController.rb
def create
@assignment = Assignment.find(params[:assignment_id])
current_user.accept(@assignment)
redirect_to @assignment
end
assignment#index
<div class="col-md-9">
<h2><%= assignment.event_title %></h2><br>
<strong>Date: </strong><%= assignment.date_start.strftime("%D") %><br>
<strong>Time: </strong><%= assignment.time_start.strftime("%I:%M %p") %> to <%= assignment.time_end.strftime("%I:%M %p") %><br>
<strong>Address:</strong><br>
<address><%= assignment.addressline1 %><br>
<% if !assignment.addressline2.blank? %>
<%= assignment.addressline2 %><br>
<% end %>
<%= assignment.city %>, <%= assignment.state %> <%= assignment.zip %>
</address>
</div>
<% if assignment.user_id == current_user.id %>
<div class="col-md-3">
<%= link_to "Update", title_assignment_path(assignment), class: "btn btn-primary btn-block" %>
</div>
<% end %>
<% if current_user.ssp? %>
<div class="col-md-3">
<%= render 'accept' %>
</div>
<% end %>
</div>
<% end %>
</div>
ruby-on-rails hidden-field
I'm trying to create an new ActiveRecord relationship taking current_user's id and assignment's id as foreign keys with a simple button press by the user. The user would be accepting the assignment and it would create that new association in a record. I already tested the models in the console and accept/decline work correctly as intended.
The error says when I click the button:
ActiveRecord::RecordNotFound in ContractsController#create
The form_for hidden_field doesn't pass assignment.id correctly, the parameter says:
"utf8"=>"✓", "authenticity_token"=>"dkGBIQxS06xiu9GR6+aYLgA6ZArgFD5iipl7HKDCFPdXhDKjX6dSajrLlrwvLlj4IzGutcX1lT51IhM5ksxt4Q==", "assignment_id"=>[""], "commit"=>"Accept"
As you can see, the assignment_id is blank. Not sure if I'm doing it right so, what's the correct way to do this?
I basically copied the code from Michael Hartl's tutorial on making Twitter, the concept is similar to an user following another user. I've already verified that the assignment record exists using find(#) in rails console myself.
_accept.html.erb
<%= form_for(current_user.active_contracts.build, local: true) do |f| %>
<div><%= hidden_field_tag :assignment_id, @assignment.id %></div>
<%= f.submit "Accept", class: "btn btn-primary" %>
<% end %>
ContractController.rb
def create
@assignment = Assignment.find(params[:assignment_id])
current_user.accept(@assignment)
redirect_to @assignment
end
assignment#index
<div class="col-md-9">
<h2><%= assignment.event_title %></h2><br>
<strong>Date: </strong><%= assignment.date_start.strftime("%D") %><br>
<strong>Time: </strong><%= assignment.time_start.strftime("%I:%M %p") %> to <%= assignment.time_end.strftime("%I:%M %p") %><br>
<strong>Address:</strong><br>
<address><%= assignment.addressline1 %><br>
<% if !assignment.addressline2.blank? %>
<%= assignment.addressline2 %><br>
<% end %>
<%= assignment.city %>, <%= assignment.state %> <%= assignment.zip %>
</address>
</div>
<% if assignment.user_id == current_user.id %>
<div class="col-md-3">
<%= link_to "Update", title_assignment_path(assignment), class: "btn btn-primary btn-block" %>
</div>
<% end %>
<% if current_user.ssp? %>
<div class="col-md-3">
<%= render 'accept' %>
</div>
<% end %>
</div>
<% end %>
</div>
ruby-on-rails hidden-field
ruby-on-rails hidden-field
edited Mar 23 at 14:44
fshenouda
asked Mar 22 at 19:05
fshenoudafshenouda
107
107
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306303%2fhidden-field-cant-find-an-active-record-by-its-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306303%2fhidden-field-cant-find-an-active-record-by-its-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown