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;








0















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>









share|improve this question






























    0















    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>









    share|improve this question


























      0












      0








      0








      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>









      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 14:44







      fshenouda

















      asked Mar 22 at 19:05









      fshenoudafshenouda

      107




      107






















          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
          );



          );













          draft saved

          draft discarded


















          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















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?