ruby-on-rails3

to_json not working because reflections are wrong

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...

how to autobuild an associated polymorphic activerecord object in rails 3

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...

ERROR Errno::ECONNRESET: Connection reset by peer

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...

Why is capybara/rspec loosing the current_user?

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 ...

Can authlogic-oid be configured to use a tablename other than session?

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...

Ajax call made by jQuery .load function...

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...

How to override a rails 3 template within a gem

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 Default Validation Error Messages in Rails 3.0?

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. ...

Rails3 and heroku image_path

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: -...

Rails 3.0.0 and FASTCGI Deployment Question

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...

Rails - Best-Practice: How to create dependent has_one relations

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...

Rails remote_function, can I set the id dynamically on the client side with javascript?

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...

Implementing a News Feed / Activity Feed on Several Models - Recommendations?

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! ...

Assistance Learning how to add this to Rails ?????

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...

rails3 html5 jquery dynamically added nested forms, presenter pattern ?

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...

Rails3: Find method not working with fixtures in test environment

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 do I create a view that is aware of full route. (Rails 3)

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...

CircularReferenceError when serializing an ActiveRecord instance (fetched by using ThinkingSphinx) to JSON

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....

default_scope not working with sessions in my tests

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...

Rails Associations Help

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...