I have a class called Foo that looks like this:
class Foo < ActiveRecord::Base
belongs_to othermodel
end
and a class Bar that looks like this:
class Bar < Foo
belongs_to thirdmodel
end
When i try to serialize bar with : bar.first.to_json(:include
=> :othermodel), it fails in production mode. Strangely it works in
th...
class ItemSource < ActiveRecord::Base
belongs_to :product, :polymorphic => true
end
class RandomProduct < ActiveRecord::Base
has_one :item_source, :as => :product, :autosave => true, :dependent => :destroy
end
What I'd like to do is is call:
a = RandomProduct.find(1)
a.item_source
and if item_source doesn't already exist (= nil...
gem 'rails', '3.0.0'
gem 'devise'
gem 'bson_ext', '>= 1.0.7'
gem 'bson', '>= 1.0.7'
gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
With the above setup I get the following errors on requests:
Starte...
The following Spec is failing and failing over again. I've tried everything but can't get it to work. If I test it manually all looks fine :( Some help/tips would be really nice!
The join-action should add an logged-in user to an guild/group if he/she got the right token (in the url). If the user isn't logged in the action redirects to ...
I'm working on a rails3 login using Authlogic and Authlogic-oid, with activerecord-oracle_enhanced-adapter, and user/session code pretty much like Holden's demo on github.
When I have a session table, I get this error, because there are no quotes around "session":
ActiveRecord::StatementInvalid (OCIError: ORA-00903:
invalid table name...
The problem is in the difference how browsers implement simple calls. The problem occurs while using colorbox extenstion (facebox variant). Content is loaded into colorbox with jquery load() function.
When the call is made by Chrome, Accept header is set to:
Accept: text/html, */*, text/javascript
In case of FireFox, header looks lik...
I have a Rails 3 project where I override some scaffold templates. This is done by placing a new template in lib/templates/erb/scaffold and adding lib to my autoload path in config/application.rb (see Rasilscasts #216).
Now, I'd like to package my work in a gem. (I'm new to gems...)
I cannot figure out how to accomplish this in a gem....
Where are the default validation error messages in Rails 3.0? What is the equivalent of ActiveRecord::Error.default_error_messages[:taken], for example? I have gotten as far as finding that ActiveModel handles the errors rather than ActiveRecord, but I can't find the errors themselves.
...
I'm having a problem where the asset tag time stamp is not being applied when image_path is used. As a result, the image is not displayed. This only happens when I push to heroku.
code:
<%= image_path 'notebook.png' %>
localhost result:
/images/notebook.png?1284326123
Heroku result:
/images/notebook.png
Heroku push output:
-...
I currently have hostingrails.com. But following their tutorial on deploying rails application with FASTCGI is not quite working... So currently I'm hosting one of my apps with them using Thin.
Currently, my host says FASTCGI and Rails3 is not supported is this true?
Besides running mongrel,thin or passenger. What other options do I h...
Could you tell me whats the best practice to create has_one relations?
f.e. if i have a user model, and it must have a profile...
How could i accomplish that?
One solution would be:
# user.rb
class User << ActiveRecord::Base
after_create :set_default_association
def set_default_association
self.create_profile
end
end
Bu...
I try this:
remote_function(:url => {:controller => '/cities', :action => 'show'}, :method => 'get')
But I get a routing error because I didnt specify an ID. But I want the ID to be able to change depending on a value that the user selects on the page at runtime. So then I tried this:
remote_function(:url => {:controller => '/citie...
Hello, I'm interested in learning how to implement a News Feed / Activity Feed on a web app for multiple models like Books, Authors, Comments, etc...
Any recommendations from the group? Gems/Plugins, or experience personally or from others on the best/smartest way to proceed?
Thanks!
...
I have the following model: (goal is to create a news feed / activity feed for my app).
Activity:
id.int | user_id.int | item_type.string | item_id.id | created.timestamp | data.string
With the intent that I can create records like:
{id:1, userId:1, item_type:Photo, item_id:33, time:2008-10-15 12:00:00, data:{photoName:A trip to the...
Job has many task, task has many notes
How should such a form look like ? With partials so I can enter the whole job from /jobs/new , and add new tasks from /jobs/2/tasks/new with possibility to add notes from there, and of course the possibility to add new notes from /jobs/2/tasks/5/notes/new ?
Is this a good place to use the presente...
The Rails Guide says, "Fixtures can also transform themselves into the form of the original class. Thus, you can get at the methods only available to that class," and gives the example,
# using the find method, we grab the "real" david as a User
david = users(:david).find
My fixtures are working ok, but when I try
memb = member...
How can I design my view such that it "remembers" its route? So that "Back" on /team/1/members/1 links to /team/1/members and /members/1 links back to /members?
I have models of team and member. Teams have many members.
My routes allow me to view all member or members on a team.
resources :teams do
resources :members
end
re...
I try to serialize an instance of my ActiveRecord model to JSON (using "render :json => @entities" or "@entities.to_json"), but I always get an CircularReferenceError ("ActiveSupport::JSON::Encoding::CircularReferenceError (object references itself)").
This only happens when the ActiveRecord instances are queried by using ThinkingSphinx....
Iam creating an application where a user can have many organisations each organisation has it's own data, things work fine on development, but when I'm in test mode it doesn't work. For example I have a class Tax
class Tax < ActiveRecord::Base
# This shouln't be neccesary according to documentation
before_create :set_organisation_id...
I have a Users model which has many Projects. But each Project are of different types. A WebApplication, DesktopApplication and so on. All these different types have their own specific fields and yet they share common fields which will be stored in the Projects table.
I have thought of this solution having multiple has_one to each of t...