ruby-on-rails

Ruby deployment server problem: Missing the Rails 2.3.5 gem.

Hi, I'm trying to install a rails server for my application. I'm using ubuntu 10.04 TLS with apache2 as web server. I made some search on google but I do not found something that help me. When I tried to connect on my application I have following error: The application has exited during startup (i.e. during the evaluation of config/envi...

has many polymorphic images through another polymorphic model

Greets to ruby developers. I'm stuck with ActiveRecord model associations. I illustrate what I want to do by a tables. I have these tables: Products: +----+-----------+ | id | name | +----+-----------+ | 1 | Cellphone | +----+-----------+ Images: +----+-------+--------------+----------------+ | id | url | imageable_id | image...

Load html.erb from different path

Hi, in my view I usually do something like this <%= render :partial => "shared/p" %> and _p.html.erb file is places into myapp/app/view/shared/_p.hrml.erb. Let's suppose I want to place this file in a cutomem folder like myapp/custom/_p.html.erb how can I load the folder custom into my app? ...

Mass edit in Ruby on Rails

Let's say you have some products which have 2 fields, a description and a stock value. How do you layout a form of all the products in an action named mass_edit with fields so a user can edit some, press submit and then save them in a mass_update? I have used nested forms in a order-order_line scenario but i can't seem to figure this o...

Rails Database Back-up Script

Hello, I currently use the script below to back-up a website but it could be improved dramatically! Please could you suggest any improvements, or perhaps alternative solutions? Currently, I only delete items after a massive amount has been reached - and this is not good. Does anyone know how I can delete items that are a month old, o...

Can only make one request to server without failure

Hey, I have a Rails application that lately is behaving very weird. If I start the server, I can do one successful request, but the next one ends with a failure (exactly the same request). This is not true for all pages, but for most with dynamic contents. When the failure occurs, I get this error: Processing StartpageController#index ...

Using Devise with Rails 3. Adding multiple roles?

We are using the devise gem for authentication in a Rails 3 application. We have multiple roles and from the devise stand-point, the roles will differ in terms of confirmation, activation and remember me functionality. The devise documentation has examples of two scopes being defined. One is the User itself and the other one is the admi...

upgrading rails 2.3.5 apps to 3.0

I would like to upgrade my 2.3.5 apps to 3.0. But i want to be careful in doing it. what are the places where i cannot rely on backwards compatibility. How do i upgrade in one step if possible? Edit: Thanks anand for the link... I also have another doubt... Is it advisable to upgrade applications that are live? Is the 3.0 beta stabl...

rails, How to build table in helper using content_tag?

Hi! I defined function in application helper: def display_standard_table(columns, collection = {}) content_tag :table do concat content_tag :thead do content_tag :tr do concat columns.collect { |column| content_tag(:td, column[:display_name]) } end end concat content_tag :tbody do ...

Adding tags to polymorphic models in rails

I'm adding tags to several models (Posts, Articles, Photos, etc). I'm aware of rails tagging plugins but prefer not to use them, as they don't quite meet my specific needs. I know the typical way of implementing polymorphic tagging support is to use 2 tables Tags, Taggings and setup the appropriate has_many :through relationships. B...

Setting a :has_many :through association on a belongs_to association Ruby on Rails

I have three models each having the following associations class Model1 < ActiveRecord::Base has_many :model2s has_many :model3s end class Model2 < ActiveRecord::Base belongs_to :model1 has_many :model3s, :through => :model1 #will this work... is there any way around this end class Model3 < ActiveRecord::Base belongs_to :model1 has_m...

How to sanitize user generated html code in ruby on rails.

I am storing user generated html code in the database, but some of the codes are broken (without end tags), so when this code will mess up the whole render of the page. How could I prevent this sort of behaviour with ruby on rails. Thanks ...

Background Rake Task Help

I would like to create a Rake task that: checks a column in a table row and if its value is false, sends an email with the row information, and then change the value from false to true. Does anyone know the best way to approach this? ...

How can I get control of gem installation locations?

Lots of confusion and difficulty related to gem installation. My gem environment: RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10] - INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /opt/local/bin/ruby - EXECUTABLE DIRECTORY: /opt/local/bin...

How to integrate Resque plugin with rails 2.3.5 application?

Hi, I am trying to integrate my rails app with Resque plugin but in the doc it is not given that where should I write the code and how to use that code when running application. May be it is not understandable for me. It would be helpful for me if any one explain it with an example application. Thanks in advance. ...

Saving model associations in the controller

I have the following models set up: class Player < ActiveRecord::Base has_many :game_players has_many :games, :through => :game_players end class Game < ActiveRecord::Base has_many :game_players has_many :players, :through => :game_players end class GamePlayer < ActiveRecord::Base belongs_to :game belongs_to :player end ...

How to use binary operators (& or |) with mongodb in ruby on rails

Have you guys ever saved your information with binary masks to improve performance? This is my case and I am also using mongodb with rails to store and retrieve it. I've used a pair of scopes using '&' and '|' to retrieve users with specific roles, but each time I run those scopes I get all the users regardless the roles... how could I ...

Call instance method from class method.

Controller ClientDocument. def upload_document ClientDocument.upload_client_document(params) end Model ClientDocument. Class method.. def self.upload_client_document(params) self.new :uploaded_data => params[:Filedata],:client_id => params[:client_id] rename_document_name(params) # Call instance method end Instance method.. ...

PostgreSql + btrim function is not working properly

Here, I have probleming in trim the value in postgresql. Please have a look. Ruby code :: if(this.modelName=="ClientOffice") { this.params="model_name="+this.modelName+"&action_name="+this.actionName+"& find_condition=btrim(clients_corporate_billings.id,' ') %3D btrim('"+validString('populateValue0','text')+"',' ') & ob...

how to login from the iphone to my rails app?

I've my rails app using authlogic for user session, I'm building an iphone-app as client of this site, how can I do with the login\logout\session management? I know that's a common question but I've tried to look for it everywhere but I can't find anything clear and useful thanks ...