ruby-on-rails

Rails - different versions on my machine

I am wondering about rails versions. I am in a project directory: when I run "rails --version" I get v2.3.4. when I run "script/about", I get a different answer, v2.1.1. in environment.rb, I have the line "RAILS_GEM_VERSION = '2.1.1' ...." Okay, so where is this rails v2.1.1? I thought maybe in vendor, but no, should there be? I ...

How to get data from SOAP::Mapping::Object in rails

I have get data through wsdl but i am getting data but i can't use it . is there any way to get proper data ? Due to spam protection mechanism i can't post source to SOF. ...

Rails foreign key logic

If I am not wrong then Rails has its own foreign key logic implemented using ActiveRecord. Is that to help performance i.e. so that you don't rely on the database for the additional processing logic or make frequent database transactions? Or is it for some other reason? ...

Why does my session expire when using PerformanceTest and not IntegrationTest?

OK, I am writing performance tests and am having trouble getting my session to persist like it does in integration tests. As I understand it, PerformanceTest is a child of IntegrationTest and any integration tests should work with performance test. However, when I take a integration test and copy it over to performance, change the Acti...

Rails City Listings

I'm relatively new to rails and I'm working on a task which requires a similar functionality to the Cities tab here: http://haystack.com/cities . I've searched all the books and can't seem to understand the logic that makes all of this possible. The only thing I can think of is reverse engineer e-commerce code to do what I want. Does any...

Active Record with Delegate and conditions

Hi, Is it possible to use delegate in your Active Record model and use conditions like :if on it? class User < ActiveRecord::Base delegate :company, :to => :master, :if => :has_master? belongs_to :master, :class_name => "User" def has_master? master.present? end end Thnx! ...

Is the facebooker plugin still applicable for developing FBConnect applications

Im trying to integrate FBConnect to my application and want to know if the facebooker plugin is still applicable now that Facebook has made some revisions to its API. ...

HTTP POST XML content from cucumber

I am trying to sending XML content through POST to a controller ('Parse') method ('index') in a simple Rails project. It is not RESTful as my model name is different, say, 'cars'. I have the following in a functional test that works: def test_index ... data_file_path = File.dirname(__FILE__) + '/../../app/views/layouts/in...

Can controller names in RESTful routes be optional?

With a standard map.resource routing mechanics and several nested resources the resultant routes are unnecessarily long. Consider the following route: site.org/users/pavelshved/blogs/blogging-horror/posts/12345 It's easy to create in routes.rb, and I'm sure it follows some kind of beneficial routing logic. But it's way too long and ...

How to use rspec's should_raise with any kind of exception?

I'd like to do something like this: some_method.should_raise <any kind of exception, I don't care> How should I do this? some_method.should_raise exception ... doesn't work. ...

Rails Globalize plugin help.

Has anyone gotten the Globalize plugin to work Rails 2.3.2 or later? If so, could you direct me to some useful info? ...

Can I map resources to a different controller?

I have my resources already defined, but a client wants to change the names of the URLs to match their brand (e.g. something like "catalog" when the resource is currently "products"). Can I specify a different controller name with a resource so I can get all the built-in resources functionality without having to actually rename the cont...

Rails: How can I lock data into a record which is sourced from many system tables?

I am currently building a rails application based around insurance. There is an admin section where the staff can control the system tables, mostly what appears in drop down lists, although some are more complex with their own associations. The main model in this application is the policy, this needs to hold/link to information in many o...

Problem with one-to-many relationship with Single Table Inheritance (Rails)

I have problem with STI and relationship in ActiveRecord. I think I missed something in the class methods, but I don't know for sure. Below is my models: class User < ActiveRecord::Base has_many :advertisements end class Advertisement < ActiveRecord::Base belongs_to :user end class FreeAdvertisement < Advertisement end class Paid...

Safely escape strings for SQL fragments for joins, limits, selects, and so on (not conditions) on Rails

In Ruby on Rails, for conditions, it's easy to make SQL-injection-proof queries: :conditions => ["title = ?", title] where title comes from the outside, from a web form or something like that. But what if you are using SQL fragments in other parts of the query, like: :select => "\"#{title}\" AS title" # I do have something like th...

Undefined method 'map' for nil:NilClass

My app seems to randomly be throwing a "undefined method `map' for nil:NilClass" error when users are trying to update their profile. But what's weird is it's saying the error happens on update, but the error line is actually in a view. Full error: users#update (ActionView::TemplateError) "undefined method `map' for nil:NilClass" On...

How can I access Active Record associations in a view?

If I have a Model like the following example class Person < ActiveRecord::Base has_many :moods end class Mood <ActiveRecord::Base end how do I change the new.html.erb allow me to choose a mood when entering a new Person? Do I need to add the foreign keys to mysql manually? ...

rubyonrails: how to find a session by a session_id

any one know how to find a session by a session_id on RoR? I'm using Authlogic in my project i don't know if that is correlated ...

Can I start and stop delayed_job workers from within my Rails app?

I've got an app that could benefit from delayed_job and some background processing. The thing is, I don't really need/want delayed_job workers running all the time. The app runs in a shared hosting environment and in multiple locations (for different users). Plus, the app doesn't get a large amount of usage. Is there a way to start a...

How to test akismet in a Rails app?

I'm using the rakismet gem to submit user content to Akismet for spam testing. So far every test I have done has classified the content as spam. I'm starting to think I'm doing something wrong. Does anyone know why I might be getting all false positives on my test data? ...