Skip to content

Instantly share code, notes, and snippets.

@nesquena
Forked from achiurizo/blog_template.rb
Created April 6, 2010 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesquena/357273 to your computer and use it in GitHub Desktop.
Save nesquena/357273 to your computer and use it in GitHub Desktop.
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord, :dev => true
#default routes
APP_INIT = <<-APP
get "/" do
"Hello World!"
end
get :about, :map => '/about_us' do
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!"
end
APP
inject_into_file 'app/app.rb',APP_INIT, :after => "#\n end\n"
# generating posts controller
generate :controller, "posts get:index get:show"
POST_INDEX_ROUTE = <<-POST
@posts = Post.all(:order => 'created_at desc')
render 'posts/index'
POST
POST_SHOW_ROUTE = <<-POST
@post = Post.find_by_id(params[:id])
render 'posts/show'
POST
inject_into_file 'app/controllers/posts.rb', ', :with => "hello"', :after => "get :show" # doesn't run?
# inject_into_file 'app/controllers/posts.rb', POST_INDEX_ROUTE, :after => "get :index do\n"
# inject_into_file 'app/controllers/posts.rb', POST_SHOW_ROUTE, :after => "get :show do\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment