jeudi 30 août 2018

Adding parameter before saving in Rails 3.2 controller

Rails 3.2

I have an API workspace in my Rails 3.2 application.

I can make calls to create tickets, and within the calls, I'm passing a list of parameters. The model has a ticket_type param, that is not passed through the API call, so I want to add that parameter, prior to saving.

Within the ticekts_controller.rb, in the create call, I added the following:

@ticket.ticket_type = 'urgent'

followed by:

@ticket.save

I am not getting any error messages, but the ticket_type in the tickets table remains NULL.

I cannot do this through the model, because this is behavior that I want to restrict only to the API controller. I've already checked the ticket.rb model, and it ticket_type is in the attr_accesible list.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire