ruby-on-rails3

How to do find() with includes() in Rails 3

I'm trying to do something like this, but it's not working. How would i do this in Rails 3? Student.find(12).includes( :teacher ) ...

Is there a benefit to creating a very generic data model for a Rails 3 Project?

A Product can have lots of things said about it, I'll call them Properties. It can have a brief description. But that description can be in multiple languages. Likewise, it can have multiple Prices, some which are specific to Customers. Given the following data: Product: identifier: 123-ABC Price: value: $1.25 currency: ...

How can I use mixins or modules in my controllers in Rails 3?

I have some behavior in my controller that I pulled out into a module in order to test better and re-use it in a few places. Two questions about this: Where is a good place to put my modules? They need to run in order to be available to the controllers, so I was thinking the config/initializers/ directory. That seems a little suspect t...

Are Rails project portable across various computers?

I'm currently developing a Rails project in my computer. I would Like to give a copy of project to my friend so that he can parallely work on the same project. Does copying the project directory to other system , help this ? Or should I do more to carry the project to different systems. ...

Accessing a RoR ActiveRecord's attributes from within the ActiveRecord instance

Hi, I am confused about how to access the attributes of an ActiveRecord instance from a method within the ActiveRecord instance. For example I have a Lead class that inherits from ActiveRecord: class Lead < ActiveRecord::Base end I have the following scaled down migration file that shows the columns of an ActiveRecord table: class ...

Rails 3 - AutoComplete with jQuery

Hello, I'm interested in using the Rails 3 AutoComplete plugin for jQuery but the one tutorial provided doesn't match my use case. Hoping for some help... Plug In: http://github.com/crowdint/rails3-jquery-autocomplete-app I have a Permissions Controller where people can add team members. On the Permissions SHOW view I want to show a a...

Rails 3 - Using LIKE to search a combined 2 columns...

Hello, I'm following ryan's Simple Search Form tutorial here: http://railscasts.com/episodes/37-simple-search-form I have the following line in my Users Model: find(:all, :conditions => ['fname LIKE ?', "%#{search}%"]) But what I'd like to do is search across a combine 2 columns,: fname & lname As users are searching my full names:...

Rails 3 - Help me setup an AJAX Search Form

Could use some help setting up an AJAX Search form for Users... config.rb - controller: resources :users, :only => [:index, :show, :searchresult] do collection do get 'searchresult' end end Model def self.search(search) if search find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) else find(:all...

Rails Twitter OAuth Strategy with Devise

I have been searching to figure out how exactly to use the oauthable module in the Devise gem for Rails 3. I have come across a couple of questions on here that seem correct, but I was unable to get the implementation working. My end goal is to have both Twitter and Facebook authentication through Devise in my Rails 3 application. Right ...

How to use a Range data-type in Rails model creation?

Am using Rails version 3. I want to create a model , in which i have a field called "Page-visits" I want it to hold range as value, eg: (50 .. 100) , (1000 .. 5000) etc. How to achieve this ?? Even if there is no such data-type at present in rails, I would like to know other ways of how to achieve this ? ...

Authlogic Rails 3

I am having a weird issue with Authlogic in Rails 3. I followed this how-to here but I get: NoMethodError in PeopleController#my undefined method `login_field' for Object:Class app/controllers/application_controller.rb:33:in `current_session' app/controllers/application_controller.rb:39:in `current_user' app/controllers/application_c...

How to remove a column from my Rails model ?

I need to remove a few columns from my rails model which i already created and have some row entries in that model. How to do it? Any links which has details for modifying the schema in rails ? I'm using rails version 3. ...

What am I doing wrong with this query?

Goal: to get a list of N random questions that have been answered correctly the least amount of times, per user. following sql will provide me a list of having a count of correctly answered questions for user_id 4. select q.id, temp.Count from questions as q left join (select q.id, count(a.id) as count from questions as q left join att...

rails session_store odd behaviour

Hi, I am using active_record_store in a rails application which is storing this in session session[:email] = "[email protected]" now this works fine in the action. but when this action gets over and is redirected to another page, which also accesses the same session[:email] I get an error undefined method `eq' for nil:NilClass this ...

Need help in troubleshooting association in Rails !!

I'm new to rails and and I'm on the urge of learning Associations. I'm using Rails version 3. I have a user model and post model.My need is as below:- Models class User < ActiveRecord::Base has_many :post end class Post < ActiveRecord::Base belongs_to :user validates_associated :user end Schema ActiveRecord::S...

Should I not be using the mysql gem now for rails 3.0 applications?

I'm starting a new rails 3.0 application that uses geometry data types in the database to store polygons. I have installed the spatial adapter gem but it requires the mysql gem and is incompatible with the mysql2 gem. Is it ok to use the mysql gem instead of the mysql2 gem? Am I going to have problems down the road? Thanks! ...

Passenger stalls with a large amount of simultaneous requests

I'm having trouble with one of our Rails 3 app's. When a lot of requests are sent to the server (10 / second) the whole server stalls. I tried a lot of different passenger setups and sometimes I noticed a slight improvement but none of them ended up to be a solution. My setup: Intel i7 (8 cores) 8GB ram Ubuntu 10.04 Server Ruby 1.9.2 ...

How do I make an RSS/Atom feed in Rails 3?

I'm pretty new to Rails 3, and I'm trying to make an RSS/Atom feed. I know about auto_discovery_link_tag, but what is the associated controller/action supposed to look like? Thanks! ...

bundle install error

I'm trying to install this gem: http://github.com/professionalnerd/simple-private-messages with bundle install. And I'm getting the following error message: Updating git://github.com/professionalnerd/simple-private-messages.git Fetching source index for http://rubygems.org/ Could not find gem 'simple-private-messages (>= 0, runtime)'...

Rails 3 ActiveRecord Questions

I have a few queries for you Rails 3 gurus out there. How can you accomplish the following? The following pseudocode is currently invalid. Thanks all. @items = (@itemsA + @itemsB).order("name ASC") @item = Item.where("type = ?" and "condition = ?", "book", "new") @commenteditems = Item.find_all_by_type_and_condition("book", "new").in...