Ruby on Rails
Friday, September 30, 2016
Ok, here is my edit products page...
here is my _form
On Friday, September 30, 2016 at 10:58:34 AM UTC-4, mode-x wrote:
-- <% if user_signed_in? %> <!-- fix this change to admin user -->
<h1>Editing Product</h1>
<%= render 'form' %>
<%= link_to 'Show', @product %> |<%= link_to 'Back', products_path %>
<% else %>
<div class="alert alert-warning" role="alert">You must be signed in as administrator to edit the products.</div> <% end %>
here is my _form
<%= simple_form_for(@product) do |f| %> <%= f.error_notification %>
<!-- fix this --> <div class = "field"> <%= f.label :category %><br/> <%= f.collection_select :category, Category.all, :id, :name %> </div> <!-- fix this, it should save the category to the model --> <div class="form-inputs"> <%= f.input :title %> <%= f.input :template %> <%= f.input :price %> <%= f.input :msrp %> <%= f.input :enddate %> <%= f.input :draft %> </div>
<div class="form-actions"> <%= f.button :submit %> </div><% end %>
On Friday, September 30, 2016 at 10:58:34 AM UTC-4, mode-x wrote:
You need to show the code for your edit
On 30 Sep 2016 3:51 p.m., "Joe Guerra" <jgu...@jginfosys.com> wrote:--I've got two tables in my Postgres database:
categories
andprodu
.cts I have a one to many relationship defined, one category can have many products.
I then created a reference and migrated the tables.
AddCategoryRefToProducts category:references
I have this in my models.
#product.rb belongs_to :category #category.rb has_many :products
I've fixed the _form to include the category id. But when I edit or update the form, the category id is not written to the product table.
I think I'm missing a step somewhere, not sure where.
Any suggestions?
Thanks,
Joe
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .8c62b187-a01f-4da3-8051- 8772215ebb3d%40googlegroups. com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6779741f-a256-422b-8aee-ace7a38cfc91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment