ruby-on-rails3

rails 3 not working with windows 7

ruby 1.8.7 gem 1.3.7 rails 3.0.0, 3.0.0.rc when i write rails -v error message come Could not find gem 'mysql2 <>=0, runtime>' in any of the gem sources. Try running 'bundle install'. when I run bundle install then also it cann't install mysql2 please help me. ...

Sorting model instaces with Globalize3

The problem seems trivial, but I can't find any resonable solution. I have list of countries with translations stored in Globalize3 translation tables. How can I fetch the list of countries sorted by name? Country name isn't stored directly in the model, but in separate table. Is there any resonable way to sort the result other than ma...

How can I include rails code inside a validation message?

validates_presence_of :match, :message => "for your name and password could not be found. Did you #{link_to "forget your password", help_person_path}?" That's what I want to do. I can interpolate variables that are set in the model, but using simple Rails code like "link_to" doesn't seem to work. Which is a bummer. ...

Rails3: Cascading Select Writer's Block

I have a big, flat table: id product_id attribute1 attribute2 attribute3 attribute4 Here is how I want users to get to products: See a list of unique values for attribute1. Clicking one of those gets you a list of unique values for attribute2. Clicking one of those gets you a list of unique values for attribute3. Clicking one of those...

Handling file uploads in Rails 3

I had a working code for Rails 2 to handle file uploads that no longer works with Rails 3. The code is: # Handling file uploads def file=(file_data) unless file_data.blank? @file_data = file_data self.filename = file_data.original_filename self.size_before = file_data.size end end Now Rails 3 doesn't like that, complai...

Rails 3: @template variable inside controllers is nil

Hello guys! I have the same problem, as in this question. Did anybody find any solutions for this? So I can't do like this: flash[:notice] = "Successfully created #{@template.link_to('product', @product)}. or like this: @template.title("Page title is here.") It worked perfectly in Rails 2.3. The main idea is to find out, how to u...

NameError: uninitialized constant Test::Unit::AssertionFailedError when upgrading to rails3

I'm trying to upgrade my rails application to Rails3. When I run functional tests, I get a lot of NameError: uninitialized constant Test::Unit::AssertionFailedError errors. But unit tests and website itself seems to work fine. Trace looks like this: NameError: uninitialized constant Test::Unit::AssertionFailedError /Users/mantas/.rvm/...

Is there a new syntax for `url_for` in rails 3?

In a plugin helper, I have: include Rails.application.routes.url_helpers url_for(:only_path => true, :controller => 'people', :action => 'new') Note that uses the new include syntax, that part works ok. But I get an error: undefined local variable or method `controller' for #<ActionView::Helpers::InstanceTag:0x311ddf4> Is there a ...

Rails 3, after_create in user.rb to create an Instance Association?

Rails 3 newbie here.... I'm looking to build an application that limits a user's viewable data to their company, which is based on their email's domain. Very much like Yammer or basecamp. I'm currently using devise for auth... I'd like a User's table and then a UserInstance Table... The UserInstance table would look like: ID | domain ...

How to stub an users_controller | authlogic, rspec2, rails3, factory_girl

My users_controller.rb # GET /users/1/edit def edit @user = current_user #@user = User.find(params[:id]) end my sweet looking users_controller_spec.rb ( notice all my commented out attempts ) describe "Authenticated examples" do before(:each) do activate_authlogic UserSession.create Factory.build(:valid_user) end des...

Rails 3 run_callbacks method

Hey guys, I'm playing around with the new Rails 3 API and I have a question regarding the new method run_callbacks(kind, *args, &block) In the following code: class User < ActiveRecord::Base before_save :say_hi after_save :say_bye private def say_hi; puts "hi"; end def say_bye; puts "bye"; end end I can explicit cal...

Creating Join Tables for has_many & belongs_to Associations

Hello, Rails 3 newbie here... I'm working to create a devise auth system that like (yammer) has instances where users belong. I have two tables Users (email, password...) belongs_to :instance Instance (domain name, active....) has_many :users I added the belongs_to and has_many to the models but the schema hasn't been updated to a...

Rails 3, I added a Table, then added a Column, now I want to add an Index

In Rails 3, I created a table with a migration, then added a column with a migration which creates a has_many, belongs_to relationship.... I then ran rake db:migrate I'd like to now add an Index because I forgot to add it before I can migrate. can I add that to one of the existing migration files (the create table one) or do I need to...

Rails 3, CanCan to limit all query results throughout the app based on User's InstanceID

Hello, I have two tables Users (name, email, password, instance_id, etc...) example: james bond, [email protected], 1 Instance (id, domain) example: 1, abc.com Through out the application I want to make sure James Bond only sees data that is assigned to his instance = 1 So if I have a books table with (name, desc, instance_id), he only ...

after_find callback broken after upgrade to rails3

Grettings! In an app that was working flawlessly in Rails 2.3.8 i have the following class method: def self.encode(*attr_names) encoder = Encoder.new(attr_names) before_save encoder after_save encoder after_find encoder define_method(:after_find) { } # defining here, since there's only alias in the Encoder class i...

how to use urlhelper to include rails 3 custom data- attribute

Hello, I am using Rails 3 and found that if I add :remote => :true, there will be added to the tag the data-remote = true attribute. But I can't find a way to add custom data- attributes to the urlhelper. The followings won't work: <%= link_to projects_path, :history => "new"%> <%= link_to projects_path, :data-history => "new"%> ...

Rails 3 equivalent for periodically_call_remote

Seems like periodically_call_remote is deprecated in Rails 3, any ideas how to achieve the same functionality? ...

Formtastic internationalization of select-tags

Could you tell me how to add internationalization for select tags in formtastic? # view .... f.input :hair_colour, :as => :select, :collection => HAIR_COLOURS .... # user.rb class User << AR validates_inclusion_of :hair_colour, :in => [0..8] end # de.yml de: profile: hair_colour: 0: "Blond" 1: "Dunkelblond" ...

Numbers in Internationalization (i18n) in rails3?

How can i use numbers in my yml files to show translations? f.e.: # de.yml profile: hair_colour: 0: "Blond" 1: "Dunkelblond" 2: "Braun" 3: "Brünett" 4: "Rot" 5: "Schwarz" 6: "Grau/meliert" 7: "Glatze" 8: "Andere" Its not working... Why? How can i fix this? ...

Using default_scope in a model, to filter by the correct instanceID

I have two tables: books (id, name, desc, instance_id) instances (id, domain) A user should ONLY be able to see data that is assigned to their instance_id in records... For the books, model, to accomplish this, I'm thinking about using a default scope.. Something like: class Books < ActiveRecord::Base attr_accessible :name, :des...