So i need this format json and i have this so far
{
query:'Li',
suggestions:['Liberia','Libyan Arab','Liechtenstein','Lithuania'],
data:['LR','LY','LI','LT']
}
query = params[:query]
artists = search_object.map{|x| x["artistName"]}
@all_instances_hash = {}
@all_instances_hash[:query] = query
for instance in artists
@all_...
When I upgraded from rubygems 1.3.5 to 1.3.7, my GEM_PATH changed. gem environment gives me
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/me/.gem/ruby/1.8
... whereas it was previously /var/lib/gems/1.8
How would you handle this?
I could set GEM_PATH, but this seems a bit messy, as I'd have to do this for my shell, and each of ...
Hi, I'd like to create a self referencing relation in rails. I have a Person model, and the person should have masters and pupils with same Person object.
So far I tried:
class Person <ActiveRecord::Base
has_many :relationships, :dependent => :destroy
has_many :masters, :through => :relationships, :conditions => "status='master'"...
Hey, I'm using TDD with rails for the first time... interesting concepts. Definitely useful. That is, until I come to this. When I run my test I get:
1) User should build the full name correctly
Failure/Error: @u1.fullname.to_s.should be("#{@attr[:firstname]} #{@attr[:lastname]}")
expected Joe Smith, got "Joe Smith"
# ./spec...
In a Rails3 app, I want to use resourceful paths for an ActiveModel EntityImage representing image file uploads. In some directory I have these files dir/#{type}/#{id}/#{size}.jpg (which are basically all important fields of that class)
Now, probably, because 'id' is a bad name rails wise (it is not domain wise), when I want to make a d...
I am attempting to create a friend network on a site I am making. I am using Mongoid. How do I instantiate friends?
I assume that Users needs to have a relational association with multiple other users. But the following code:
class User
include Mongoid::Document
references_many :users, :stored_as=>:array, :inverse_of=> :users
en...
i've got a jruby regex that i'm printing in rails:
@@private = /somethingthatshouldnevermatch/
def secure?
puts "security test(#{action_name}/#{@@private}: #{@@private.match(action_name).nil?.to_s}"
action_name =~ @@private
end
on os x, using WEBRick and jruby, this prints
security test(index/(?-mix:somethingthatshouldnevermatch...
Hi,
could you tell me plz - is it possible to disable warden/devise for one or more controllers/actions?
I need to allow requests with basic auth to one of controllers, but everytime i send similar requests i've seed message, that basi auth is not required for my app.
I'm writing oauth2 provider and its a problem to allow client applic...
I'm following part of this Railscast and trying to load a static file using Rack when a specific route is called:
match "/myApi.js" => lambda { |env| [200, {}, Rack::File.new("/v1/myApi.js")] }
No matter what I do, even if I just try to send a string through:
match "/myApi.js" => lambda { |env| [200, {}, "Hello World"] }
I still re...
I've been working through some issues getting rails to behave nicely with sqllite, and decided to move over to mysql.
I ran my rake db:create and rake db:schema, and assumed everything was ok, but then mysql show tables displayed a complete table was missing.
I created a migration with the create table details and ran rake db:migrate,...
I already have a form with normal HTTP post. Now, I want to rewrite this form usign jQuery Ajax request. Here is what I have:
register_user.html.erb
<%= form_tag :action=> "register_user" %>
<label for="user_id_1">user_id_1:</label><br/>
<%= text_field "user", "user_id_1", :...
I have following models in my app:
class Game < ActiveRecord::Base
has_many :players
has_many :villages, :through => :players
end
class Village < ActiveRecord::Base
belongs_to :player
end
class Player < ActiveRecord::Base
belongs_to :game
has_many :villages
before_create :build_starting_village
protected
def...
I am thinking of running my cucumber tests on my rails app when it is running on heroku. Is this a sane way to check for differences between development environment and deployment environment?
Does anybody have any experience of this kind of scenario? Rake -T tells me "cucumber rake task not available (cucumber not installed)" even thou...
Guys,
I've got a controller called "ResourcesController", but its really managing the CRUD for two different models.
I don't actually have a model called Resource, so the controller is balking that it can't find it.
Is there a way I can inform the controller which model I'll be working with so it doesn't freak out?
The error that is ...
Supposed we have something using Mongoid:
data:
'products':
"2010-09-07":
{ pageviews: 123
timeOnPage: 1823 }
"2010-09-08":
{ pageviews: 138
timeOnPage: 2607 }
...
So 2, 3 years down the road, there will be 700 or 1000 dates mapping to a hash. If we modify 1 number, will it require readin...
Suppose I have an object Person, which has_many :foos and :bars.
Given an instance, p (p = Person.new), how do I programmatically determine what relationships are available?
i.e. p.some_method => ["foo", "bar"]
...
I have a Rails site. I want to create a news feed.
Does anyone have any pointers/advice/caution with this?
What are some common schemas?
We're using ActiveRecord+MySQL (at least for now), should that be sufficient, or is NoSQL the way to go?
...
I am using javascript to select a file and then to show the file upload progress. I would also like to be able to modify other attributes of the file.
<script type='text/javascript'>
var swfu;
window.onload = function () {
swfu = new SWFUpload({
upload_url : '<%= new_image_path_with_session_information %>',
flash_url : '/flash/s...
So I'm getting started learning Rails. Now that Rails 3 is out, I want to stick to learning the Rails 3 way of doing things. One of the things I want to learn how to do is how to consume web services / work with third party REST APIs / create "mashup" applications. I've only done minimal work like this with PHP and pre-built libraries.
...
I am developing a web-based application using Rails. I am debating between using a Graph Database, such as InfoGrid, or a Document Database, such as MongoDB.
My application will need to store both small sets of data, such as a URL, and very large sets of data, such as Virtual Machines. This data will be tied to a single user.
I am in...