Now on Posterous Spaces: Embeddable Tweets post.ly/4BqnN
— posterous (@posterous) December8, 2011
Now on Posterous Spaces: Embeddable Tweets post.ly/4BqnN
— posterous (@posterous) December8, 2011
if you wanna make a cross-domain get request, jsonp would be a nice solution.
on client side, if you use jquery then you would write something like this:
$.ajax({ url: 'http://other.domain.com/api/songs.json', type: 'GET', dataType: 'jsonp', success: function(data) { ... } });
and on server side, by using rails 3, you can write this:
render :json => @songs.to_json, :callback => params[:callback]
if you try to write this kind of SQL in rails:
'query' LIKE CONCAT('%', LOWER(field_name), '%')
since this will only work in MySQL, if you wanna apply on SQLite, there are two ways you can try:
add this method to your code (originally from here):
# Symbols should be used for field names, everything else will be quoted as a string def db_concat(*args) adapter = configurations[RAILS_ENV]['adapter'].to_sym args.map!{ |arg| arg.class==Symbol ? arg.to_s : arg } case adapter when :mysql "CONCAT(#{args.join(',')})" when :sqlserver args.join('+') else args.join('||') end end # in your find() method :conditions => [ "? LIKE #{db_concat("\'%\'", 'LOWER(field_name)', "\'%\'")}", query.downcase ]
use gem like this one: https://github.com/adamcrown/port-a-query (only works for MySQL and SQLite)
there might be more gems solving this issue, but anyway, since i am not doing things so complicated, i choose the first approach.
require 'will_paginate'WillPaginate.enable_activerecordWillPaginate.enable_named_scope
location: ~/.gem/credentials
but if you have multiple accounts like me, this is the gem you might be looking for: