I am working on Address book and i face problem regarding how to added
dynamic column by each user. one things is each user display its own
column  after add column how to submit all values inside one form.

 view (e.g consider mike is user and its create name,city and address
dynamic  column how three row inserted into database. )

<h1>Add Field values</h1>

<%= form_for(:detail, :url => {:controller => 'details', :action =>
'create'})  do |f| %>

  <% @info.each do |a| %>
    <%= f.hidden_field :columns_id, :value =>a.id   %>
     <p>
      <td><%= a.value %></td>
      <td><%= f.text_field :column_value %></td>
    </p></br>
  <% end %>

  <%= f.hidden_field :users_id, :value => current_user.id  %>
  <p class="button"><%= f.submit %></p>

<% end %>


controller


class DetailsController < ApplicationController
  def new
      @detail = Detail.new
       @info = Column.where(:users_id => current_user.id).all
  end

  def create
    @detail = Detail.new(user_params)
    if @detail.save
      redirect_to new_detail_path, :notice => "Added Sucessfully!"
     else
      render "new"
    end
  end

private

  def user_params
      params.require(:detail).permit(:users_id,:column_value,:columns_id)
  end
end

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/02fbd77a70c5a062a8539b7712f9820d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to