ruby-on-rails3

Alias for specific resourceful route's action ("/sign_in" instead of "/sessions/new")

I set up restful authentication and user management without any gems in Rails 3. However, I think it's silly to need to go to "/sessions/new" instead of "/sign_in". I know you can alias an entire resource, so that instead of "/sessions"-and-friends my users could use "/squirrels"-and-friends, but that's not what I'm trying to accomplis...

Cucumber newb question..

I am having trouble showing a mock logged in user in cucumber. When a user is logged in they can, make a post. My Errors: (::) failed steps (::) undefined local variable or method `user' for #<Cucumber::Rails::World:0x85974df4> (NameError) ./features/step_definitions/tasklist_steps.rb:25:in `/^that I want to post a link$/' featur...

Rails 3rc and Authlogic 2.1.6 functional testing

In Rails 3 rc testing of my controller I can't login with user from fixtures nor (:email=> '', :password =>''). The session object is created but it's user is empty. Everything done just like in manual. And it was worked in rails 2.3.8. I've tryed to: require 'test_helper' require 'authlogic/test_case' class UsersControllerTest < Act...

Rails: Warden/Devise - How to capture the url before login/failed access

Hi: I am trying to figure out how to redirect a user to the page they logged in from (or failed to login) using Warden/Devise. I figure there is a session variable somewhere that is either available or could be made available. E.g. Scenario 1: Non-authorized user goes to protected page X; Redirected to login page; User logs in; User re...

Ror Active Record "component" classes

Hello, coming from my experience with nHibernate, I wonder how one maps (n)hibernate's component classes in ActiveRecord class Person < ActiveRecord::Base #somehow get a :name attribute here end class Name @fist_name @last_name end how can this be done with one table only (so this is no 1:1, but i want to have a :name_first_na...

How to install Rails 3 master from GitHub

I'm using rvm (Ruby Version Manager) and running Rails 3 RC. I need to test an app to see if a bug has been resolved with a recent commit to Rails 3 master on GitHub. How do I install Rails 3 master from GitHub and then generate a new app? I can't use gem install rails --pre because I want the edge version, not the release candidate. ...

Access Rails Method Defined In Model Through View In Rails 3

I have a method defined in my controller that I am trying to create a button or form to access. Model class DoThis < ActiveRecord::Base def take_action(a, b) end end View <%= @do_this.take_action(@a, @b) %> I would like to convert the above code in the View to a button_to or form_for but cannot figure out how. Thanks ...

Rails 3.0 or Old Rails

I am a developer who has stepped into the world of Rails very recently. I have learnt Rails 2.3.8 and have now landed into a major project in rails. The question we are facing is this: "Should we use Rails 3.0 for development or the older version?" Our project has a time frame of 4 to 6 months for its release. Will Rails 3.0 be out of b...

Geokit Gem 1.5 and Ruby 1.9.2 => "incompatible character encodings: UTF-8 and ASCII-8BIT"

Hi there, I am currently writing a rails app using bleeding edge stuff. Rails3, rSpec2, Ruby 1.9.2 and Geokit 1.5.0. When i try to geocode addresses that have special characters that are not in ASCII-8Bit i get this error: incompatible character encodings: UTF-8 and ASCII-8BIT The Trace is like this: 1) Spot Basic Validations s...

Class Table Inheritance in Rails 3

I'm currently working on a Rails 3 application that looks like it might need to use Class Table Inheritance for a couple of models. A simplified example of what's going on is this. I have a class called Person with general attributes like name, email, password which are common to all types of people in the application and used for auth...

rails3 rails.js and jquery catching success and failure of ajax requests

Previously, in rails 2.3.8 i used the prototype-helpers link_to_remote and form_remote_for (amongst others). These had the option :update as follows: link_to_remote "Add to cart", :url => { :action => "add", :id => product.id }, :update => { :success => "cart", :failure => "error" } (an example from the documentation). This exam...

Rails 3 app server startup time is long

update: This started out as a question, but after working on this for a bit I think it might not be fixable. I figured I would post this in case anyone else is seeing the same thing and is wondering what is going on inside rails and bundler. Is anyone else seeing long load times in their Rails 3 apps? I placed timers in environment.rb...

Bi-directional polymorphic join model in Rails?

I'm working on a multi-site CMS that has a notion of cross-publication among sites. Several types of content (Articles, Events, Bios, etc) can be associated with many Sites and Sites can have many pieces of content. The many-to-many association between content pieces and sites must also support a couple common attributes for each conte...

Cucumber Help in Rails 3

I am very new to cucumber and rspec, but do have some rails and ruby understanding. The gems in question are: Devise, Declarative_Authorization, and role_model Rails 3 is what I am using and ruby 1.9.2-rc2 remember I do NOT know what I am doing I have written a Feature: Feature: As the administrator of the site give me quick access ...

Upgrading :with parameter on a link_to_remote in Rails 3

What's the preferred UJS replacement for the Rails RJS helper ':with' parameter on a link_to_remote when upgrading to Rails 3 (using the new unobtrusive link_to... :remote => true syntax). eg. Replacement for: link_to_remote "Ajax Call", example_path(@thing), :with => "'foo=' + $('field').val()" Specifically, I'm looking into a link ...

Polymorphic assosciation question

Hello! In my Rails app I have models that look something like this: class Blog < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :blog end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end What I'm having problem with now is finding all comments under a spec...

remote form_tag in rails3 without a named route

what is the proper incantation to make this actually post asynchronously? form_tag :controller => :magic, :action => :search, :method => post, :remote => true do method=post and remote=true just get squashed on the end of the url instead of actually making it an ajax post. ...

Ruby on Rails 3: Streaming data through Rails to client

Hi, I am working on a Ruby on Rails app that communicates with RackSpace cloudfiles (similar to Amazon S3 but lacking some features). Due to the lack of the availability of per-object access permissions and query string authentication, downloads to users have to be mediated through an application. In Rails 2.3, it looks like you can ...

Porting PHP function to Ruby

So as you all probably know already, there is no facebook API for Rails 3 (not well-supported/documented anyway). I am wondering whether porting these PHP API to ruby is a good idea or not. What I mean by porting is writing my own php function that uses FB API and use the output as the ruby input. Is this a good idea? Impossible? ...

Is Rails 3 modular like Merb and Ramaze

Hey, Will Rails 3 be a modular framework like Merb or Ramaze? By this I mean, can we use any persistence framework (DataMapper or Sequel) and jQuery in Rails 3 application (via the command line for example)? Or the default stack (ActiveRecord, Prototype) is still enforced? (Sorry, I'm pretty new to Ruby/Rails community). Thanks. ...