Here’s a variety of methods for accomplishing infinite scroll with Ruby on Rails. This functionality is sometimes referred to by a variety of names including Infinite pagination, ajax pagination, endless page. These methods utilize will_paginate or kaminari gems and some … Continue reading
Tag Archives: ruby on rails
RSpec cheat sheet – $ cheat rspec
Link
How I learned to test my Rails applications, Part 1: Introduction
Link
How I learned to test my Rails applications, Part 1: Introduction
And related resources for testing Ruby on Rails applications:
- http://asciicasts.com/episodes/158-factories-not-fixtures
- http://railscasts.com/episodes/71-testing-controllers-with-rspec
- http://railscasts.com/episodes/275-how-i-test
- More in depth, complete application development; http://ruby.railstutorial.org/
- And the RSpec book: http://pragprog.com/book/achbd/the-rspec-book
Ruby on Rails Callback Overview; before_create, before_save etc
Link
Ruby on Rails Callback Overview; before_create, before_save etc
Here is a simple overview of the Ruby on Rails Callbacks in relation to creating or updating a record. Each of these Callbacks can be used to execute specific code throughout a Create or Update operation.
- before_validation
- before_validation_on_create
- after_validation
- after_validation_on_create
- before_save
- before_create
- Database Insert / Update
- after_create
- after_save
How to run a single rails unit test – Flavio Castelli
Link
How to run a single rails unit test – Flavio Castelli
Examples of running a single unit test with Ruby on Rails.
resources: Ruby on Rails deployment with CentOS, apache, mysql, cpanel, passenger and more…
Link
Simple static pages in ruby on rails.
Link
Simple static pages in ruby on rails.
— April 2, 2008 at 09:38 PDT
Simple things should be simple, complex things should be possible. — Alan Kay
Here’s a tiny little tip for handling those boiler-plate pages that aren’t part of your app’s functionality but you usually need anyway. It’s good for setting up about, contact, copyright, etc. You can always throw those pages into /public as static html files, but if you want them to get styled with layouts, they need to be rendered as actions. This is a way to do that simply. It’s not rocket science, but I haven’t done a noob post in ages and I’m getting over a cold and I haven’t posted in too long so gimme a break.
Say you want to have a simple landing page and a few typical boiler-plate pages. Let’s start with the routes.
In config/routes.rb
map.root :controller => 'home'
map.home ':page', :controller => 'home', :action => 'show', :page => /about|contact/
In app/controllers/home_controller.rb
def index
# render the landing page
end
def show
render :action => params[:page]
end
Throw your about.html or about.html.erb and other pages into app/views/home and you’re good to go. If you’ve set up page caching, this won’t even slow your app down.
The :page => /.../
bit in the route constrains it to match only those specific urls. If you want, you can change that to a constant, like HomeController::
PAGES, so it’s easier to manage.
If you want to link to those pages, you can use the route helper methods, home_path
and home_url
link_to 'About', home_path('about')
You could always unroll the routes and have a separate route for each page, but I find this way a bit drier. But if you’d rather have a specific named route helper for each page, that’s an okay way to go. Either way, you get to use layouts in your pages, and have a nice simple way to get them rendered.
Using Capistrano with Passenger (mod_rails)
Link
WebHome < AllDocumentation/RubyonRails < TWiki
Link
Ruby on Rails application deployment strategies
Using Capistrano with Passenger (mod_rails) | Ruby on Rails http://www.gotripod.com/2008/11/22/rails-deployment-is-so-easy-these-days/ http://www.zorched.net/2008/06/17/capistrano-deploy-with-git-and-passenger/