Oskar Szrajer wrote:
> I've something like that:
> 
> in layout :
> links looks that :
> 
> <%= link_to month.strftime('%B, %Y'),
> "/?y=#{month.strftime("%Y")}&m=#{month.strftime("%m")}" %>

Don't write a raw URI path and query, and don't use string surgery to create 
one. Add those items as the arguments to url_for():

  <%= link_to month.strftime('%B, %Y'),
       :y => month.year, :m => month.month %>

(BTW naming a date 'month' is kind'a tacky...)

That would escape your URI correctly, but this can't be your problem because 
either way these are just numbers, not punctuation that needs escapes.

> in controler I've :
> 
>  if params[:y] && params[:m]
>       @posts = Post.find(:all,:order => 'created_at' ,:conditions =>
> ['extract(year from created_at) LIKE ? AND extract(month from
> created_at) LIKE ?', params[:y], params[:m]] )
>     else
>       @posts = Post.find(:all)
>     end
> 
> 
> but in console I've got that sql code:
>  SELECT * FROM "posts" WHERE (extract(year from created_at) LIKE E'2009'
> AND extract(month from created_at) LIKE E'01') ORDER BY created_at
> 
> looks like this E near that LIKE broke everything

I can't see where the E comes from, but why the LIKE? Your year and month have 
no % in them for LIKE to wildcard.

Can your "functional" test call this action correctly?

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to