mercredi 13 mai 2015

Why is my button_to creating blank entries? Ruby on Rails 3

It seems like the params are not getting passed into the controller action. I'm trying to create an entry into the svc_tickets table using button_to. But I'm only getting blank entries into it.

This is the button_to

<td class='create_service_ticket' style="width: 7%"><%= button_to('Create Service Ticket',
                                                                          {controller: :svc_tickets},
                                                                          params:{
                                                                                  priority_level: 3,
                                                                                  summary: event[:signature_name].to_s,
                                                                                  description: 'description',
                                                                                  closed: 0}) %> </td> 

SvcTicktsController

  def create
    @svc_ticket = SvcTicket.new(params[:svc_ticket])
    respond_to do |format|
      if @svc_ticket.save
        format.html { redirect_to :back, notice: 'Svc ticket was successfully created.' }
        #format.json { render json: @svc_ticket, status: :created, location: @svc_ticket }
      else
        format.html { render action: "new" }
        format.json { render json: @svc_ticket.errors, status: :unprocessable_entity }
      end
    end
  end

This is from the page source

  <form action="/svc_tickets" class="button_to" method="post">
    <div>
      <input params="{:priority_level=>3, :summary=>&quot;drop - SERVER-WEBAPP RevSlider information disclosure attempt&quot;, :description=>&quot;description&quot;, :closed=>0}" type="submit" value="Create Service Ticket">
      <input name="authenticity_token" type="hidden" value="qWjFT8JDEUPXceQN3taodnInwerVEiCIKayJKBoEoTs=">
    </div>
  </form>

Aucun commentaire:

Enregistrer un commentaire