On 23 May 2013 12:56, Mateusz Urban <[email protected]> wrote:
> Hi!
> Reading "Rails For .NET Developers" i started to consider the example of
> building the flight system with cancellations. So, I've generated flights
> scaffold and passengers scaffold and I'd like that we could cancel the
> flight and then, each of the passengers would be informed about that fact.
> So, firstly i've written a non-rest code and simply added "cancel_flight"
> method to my FlightsController and generated required routes in routes.rb.
> And it looks like this:
>>>
>>>   def cancel_flight
>>>
>>>     flight = Flight.find(params[:flight])
>>>
>>>
>>>
>>>     flight.cancel_flight
>>>
>>>
>>>
>>>     redirect_to flights_path
>>>
>>>
>>>
>>>   end
>
> (where Flight model has a method cancel_flight, which of course knows what
> to do)

There is no need for a separate controller, one way would be to handle
it within the flights controller Edit action, using a url parameter or
the Submit button name to indicate that cancel is required rather than
edit.
However, REST should not be treated as a religion to which all
requirements must bow.  I would say there is nothing wrong with what
you have done (provided that you have used a POST to do it).

Colin

-- 
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/CAL%3D0gLuWuNFDdrWHujGYaGkfw4%3DUKtew61Fhz9U%2B67OEdWHz%3Dw%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to