0

There are 2 "actions" in Sinatra

get '/default1' do
 haml :"default1_view"
end

post '/default1' do
 if params[:button_name] = "clear_filter"
    #how do I return "get '/default1'" view from here?
 end

 #filtering the result
 haml :"default1_view"
end

How do I call another "action" from post '/default1' without redirect?

Note that I need to retrieve only the result from "get '/default1'" to show it as a result at post '/default1'

Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • 1
    The same? [Calling Sinatra from within Sinatra](http://stackoverflow.com/questions/3551746/calling-sinatra-from-within-sinatra) – Yevgeniy Anfilofyev Jan 11 '13 at 06:19
  • 1
    return one view inside `if` and another one in `else`. Is that what you mean? Otherwise I don't understand your problem. Maybe you post a better example or some real code. – three Jan 11 '13 at 13:00
  • @three, there are some calculations and locals: hash values at get '/default1' method. I can't only return the "naked" view. – Alan Coromano Jan 11 '13 at 14:41
  • I agree with @three, a little bit more code from the `get` would be helpful. Regardless, if you've got code within the `get` that you wish to call within the `post` as well, then I'd suggest you define a `helper` or move the code outside the route some other way. – ian Jan 11 '13 at 22:44
  • @iain, it's not necessary since there is another way YevgeniyAnfilofyev mentioned about. – Alan Coromano Jan 12 '13 at 02:58
  • @AlanDert that may have given the correct answer, but in my opinion it's a horrible solution. There are plenty of other ways to do what you're doing without resorting to that. – ian Jan 12 '13 at 15:05

0 Answers0