ruby on rails - Updating multiple check_box_tag in show page -


i trying update multiple check boxes in show page . stuck on how , lot of online has confused me. still rails noob. im using rails 4.

*edit*

the error missing template lottery/create, application/create {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}.

here controller page

class lotterycontroller < applicationcontroller    before_filter :authenticate_user, :only => [:new, :show,:update]    def new     @winner = lottery.pickwinner()   end    def show     @conferences = conference.all     #@lead = lead.all     @leads = lead.new   end    def update   end end 

and show.html.erb page controller

     <body>        <%= form_tag %>     <% @conferences.each  |c| %>      <table class = 'table table-striped table-responsive table-bordered table-  condensed'>         <h1> conference : <%= c.name %> </h1>         <tr>             <td><b>first name</b></td>               <td><b>last name</b></td>             <td><b>email</b></td>                <td><b>department</b></td>               <td><b>title</b></td>             <td><b>company</b></td>          </tr>         <tr>             <% @leads.get_lead_by_conference(c.id).each |l| %>                 <td>  <%= l.lead_first_name %> </td>                 <td>  <%= l.lead_last_name  %> </td>                 <td> <%= l.email %> </td>                 <td> <%= l.department %></td>                 <td> <%= l.title %> </td>                  <td><%=l.account_name %> </td>              <td><label for="lead">enable lottery</label><br/>         <%= check_box_tag "leads_checkbox[]",l.id %> <%= l.lotter_flag %>               </td>          </tr>             <% end %>     </table>         <% end %>  <%= submit_tag "select winners" %>    <%end %>    </body> 

edit get_lead_by_conference_id(conf_id ) under lead model

def get_lead_by_conference(conf_id)         #  leads correspond conf id      lead.where(:conference_id => conf_id) end  

so trying in show page have multiple tables separated these conferences. in each conference have lead , want select winner in each conference lottery. attribute in leads model boolean lotter_flag. want update leads marked checked box after clicking submit button. few things has stomped im updating leads model under different controller. in advance , apologize if have format errors.

the problem in show method,you have given @lead = lead.all , in show.html.erb,you using @leads given lead.new in show method.it doesn't make sense , literally performing each on lead.new wrong.

try changing show method this

def show @conferences = conference.all  @leads = lead.all @lead = lead.new  end  

note: , per rails covention,controller classnames should plural.in case should lotteriescontroller not lotterycontroller. although convention not issue recommended.

update

with regarding error,rails looking file called create.

you should changing form_tag in show.html.erb this

<%= form_tag :action => "create" %> 

and should having create method in controller.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -