error handling - How do I stop controller execution after using redirect_to? (Using Rails) -


I have a controller with a number of actions: take: I have made a personal law check-date so that it can check The date is valid and the date has not been checked in the future.

  def check_date (year, month) if month & lt; 1 || Month & gt; 12 || Year & lt; 2000 Flash [: Notice] = I18n.t' archive.invalid_date 'redirect_to: action = & gt; 'Index' Elsef Year & gt; Date (year == DateTod.And.and; Month & gt; DateTod.mm) Flash [: Notice] = I18n.t' archive.no_future 'redirect_to: action = & gt; 'Month_index' ,: year = & gt; date. today. Year, month = & gt; Date.Today.month ,: type = & gt; Parameter [: Type] End End  

Is there a rail way to end controller execution after Reader_?

The way in which I can think either throws an exception after redirect_to or returns a value from check_date and checks it in each call - such as

  def Month_index year = params [: year] .to_i month = params [: months] .to_i if! Check_adet (year, month) Return ... and  

But I wonder if there was some good way to do this, I was hoping half that I wanted to stop calling Radio Rio But I do not think so. >

You probably want to use filters.

If you call your check_date in the controller to before_filter , it is shown that the redirect will call the controller anytime from the action methin. It ends there and then.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -