Created
November 9, 2010 06:03
-
-
Save robyurkowski/668773 to your computer and use it in GitHub Desktop.
Weird routing error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag('/posts/results/', {:id => 'search_form'}) do -%> | |
<%= text_field_tag :search, nil, {:style => 'display: none;', :id => 'search_field' } -%> | |
<%- end -%> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Routing Error</h2> | |
<p>No route matches "/posts/results"</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
scope :published, lambda {|val| where(:published => (val == true ? true : false)).order("created_at DESC") } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
def results | |
params[:search] = params[:search].blank? ? '%' : "%#{params[:search]}%" | |
@posts = Post.where("body LIKE ? OR title LIKE ?", params[:search], params[:search]).published(true).paginate(:per_page => 5, :page => params[:page]) | |
render :action => :index | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blog::Application.routes.draw do | |
resources :posts do | |
collection do | |
get :results | |
get :drafts | |
end | |
resources :comments do | |
post 'disemvowel', :on => :member | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment