ruby-on-rails

Facebook Connect site with facebooker and Rails Login/xd_receiver issue

Hello. I am building a Rails (2.3.5) site with facebook connect functions via the facebooker plugin. When logging in via the facebook login button (<%= fb_login_button%>). After the popup button requests my username and password, I get a blank popup screen, and this error in the console. Processing ApplicationController#index (for 127.0...

jruby/activerecord-jdbc/tomcat/DB2 ready for enterprise?

I am trying to introduce RoR to my company and I have two ways of doing so in my mind: (1) rails/ibm_db2/passenger/DB2 - which is my preferable way but it is not really supported by company's infrastructure. (2) jruby/activerecord-jdbc/tomcat/DB2 - probably easier way to migrate relying on current infrastructure and java libs IF I have...

Use Rails select_month and select_year to capture and store dates

I would like to use two picklists to control entry into a date field; I'm concerned with the month and year, not the day. So far, I have the following: <tr> <td>Date Range:</td> <td> <%= select_month(Date.today, :field_name=>"dateStarted") %> <%= select_year(Date.today, :field_name=>"dateStarted") %> &nbsp;to&nbsp; ...

error messages displaying in wrong order when using accepts_nested_attributes_for

I guess I am running into a lot of issues related to error messages, another one. I have the following in my model class Recipe < ActiveRecord::Base has_many :recipe_ingredients validates_presence_of :title, :message => "Recipe title cannot be left blank" validates_presence_of :servingsize, :message => "Please enter a serving s...

Rails - Find results from two join tables

I have have 3 Tables of data and 2 Join Tables connecting everything. I'm trying to figure out a way to query the results based on the condition that the join table data is the same. To explain, I have User, Interest, and Event Tables. These tables are linked through an HABTM relationship (which is fine for my needs since I dont need ...

ActiveRecord not returning an iteration when there is only one record found

This might be simple but I'm starting out with rails. I have the following statement: @subjects = Cartitem.find_by_cid(session[:customerid]) In my View I have some code like this: <% @subjects.each do |d| %> <tbody> <tr> All works when when the above query returns multiple rows. However, when above query returns only one row t...

WYSIWYG editor for Rails with Paperclip Integration

I'm looking for a way of integrating a WYSIWYG editor into my rails app so it will use Paperclip for Image / File uploads. What I want is this: User can use a WYSIWYG field to create some rich text. They can upload an image into this text but the image will be stored nicely in a DB (hopefully using something like Paperclip) instead of j...

Ruby on Rails Moving from CSV to FasterCSV

I currently have the following code to parse a csv file using the standard csv library @parsed_file=CSV::Reader.parse(params[:dump][:file]) @parsed_file.each do |row| #some code end I want to move this to faster csv for the increased speed. Does anyone know the equivalent of the above for FasterCSV? Thanks ...

Running Jobs when DB is free on Ruby on Rails Heroku

I have a ruby on rails app that uses Heroku. I have the need to run things like import/export tasks on our db that lock up the whole system since they are so heavy on the DB. Is there a way to tell the system to only run these tasks when the database is not being used at that second? ...

how to override a validation call in activerecord in a gem?

I am using apn_on_rails for iphone push notification with rails. Right now, the validation on token is no longer valid because the validation requires a space every 8 characters: validates_format_of :token, :with => /^[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}$/ http://github...

ActiveRecord query help .count

I have a DB table users that has the following columns: id, clan_id, experience I want to run a query using rails that returns the top 50 clans based on experience. How would you do this query in rails? Clan Table to User Table is a one to many relationship. Thus a clan is composed of multiple users that have the same id. ...

Render w Params or Redirect w Errors in Ruby on Rails

I am using ruby on rails and have things on my site that users can click to save and they are redirected to a page with both a login and a signup so that the user can continue with either option and save the content. The creates a problem for showing the proper user validation errors, b/c I need to use a redirect_to users/new in order t...

How can i order the eager loaded model in rails

Hello All, I shot a find query to include certain models in rails but i want to order the included models by my custom criterion. I have shot the query like the following to fetch the qualifications associated with the user ordering the qualifications by the start_date: @user = User.find @current_user.id, :include => [:profile, {:...

How to have condition in ActiveRecord update

I am trying to update a record. Am using the following code. Proddiscount.update({:prodid => params[:id]}, {:discount=>params[:discount]}) Query Im trying to have is: update proddiscount set discount = '' where prodid = '' ...

Can't dup NilClass on association methods

I'm using rails 2.3.5 and ruby 1.8.7. I'm building a simple TODO manager. Where I have tasks that belong to a user and a user has many tasks. I'm using acts_as_taggable_on_steroids plugin for tagging tasks and restful_authentication plugin for registration and user management. I'm getting a weird error that reads "Can't dup NilClass" ...

Syntax question

What are these variables? Class User TOTO = 1 TITI = 2 end User::TOTO # 1 User::TITI # 2 any links to the doc? Thanks, ...

Why is rails trucating TEXT column to 65535 chars?

I am saving a raw email in a TEXT column in MySQL with Ruby on Rails. It keeps getting truncated to 65535 characters, does anyone know what causes this? MySQL is running with max_allowed_packet=64M ...

Rails: Undefined method 'to_sym'

I'm getting the following error in my deployed Rails 2.3.5 application: NoMethodError (undefined method `to_sym' for nil:NilClass): My local testing install of the application, which uses Sqlite, doesn't get the error, but my deployed app running Mysql does. The only other difference between the two is I'm running Ruby 1.8.7 on my loc...

nested form that is placed on many pages throughout application

Hi I have a form with nested attributes that I need to place on many different pages. Not necessarily the model it belongs to. So I have this form on the battalions show page. The user information is created just fine, but the user has_many roles and these attributes are not being created. I have many other nested forms that work just f...

Rails: App Templates / script generators with HAML?

Is there any way to create an app template in Rails that generates the views in HAML rather than ERB? App Templates: http://railscasts.com/episodes/148-app-templates-in-rails-2-3 If not, are there any plugins/gems that I can use to have all my generator scripts output HAML instead of ERB? ...