ActionController 中的基本 Sinatra DSL
Astaire allows the use of the basic Sinatra get / post / put / delete DSL inside of Rails controllers. This allows defining quick actions without having to update config/routes.rb. For example:
class ContactController "I say: hello"
# /say/hello/world => "I say: hello world"
#
get "/say/:one(/:two)" do
words = [params[:one], params[:two]].compact.join(' ')
render :text => "I say: #{words}"
end
endIt is possible to name actions such that regular URL helpers can generate them.
class MyController hello_path
end
get "/hello", :as => :hello do
render :text => "hello"
end
endAstaire supports inline templates in the same style as Sinatra. For example:
class MyController < ActionController::Base
get "/hello" do
render :greetings
end
end
__END__
@@ greetings.html.erb
Greetings to you.I guess, at this point I'm just putting what I have into the wild. Next steps will be determined by feedback that I get.
暂无开放 Issues,或尚未同步最近议题。