ruby-on-rails3

How do I use Rail3's AREL by itself?

I'm intrigued by Nick Kallen's AREL package and would like to use it in a project. However, I can't figure out on how I need to initialize it to work with a specific database/store backend. Any pointers? ...

Has anyone got Rails3 up and running with DataMapper on WindowsXP?

I've tried following the directions listed here, but it seems damn near everything in the ruby/rails community is NOT designed with windows in mind. Had to install MINGW32 and MSYS to even get native gems to compile. Had to install the Git Bash as the templates that are run assume you've got git functioning on your system. Depending on w...

Why can't rails3 find ApplicationController when it is in my application

In a Rails3 Application I keep getting ..gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:459:in 'load_missing_constant': uninitialized constant ApplicationController (NameError) Even though app/controllers/application_controller.rb exists and is valid. What is the problem ...

form.submit() missed by rails.js UJS observer

In a Rails 3 app, I want to make the browser call a remote function whenever a certain checkbox is toggled. In Rails 2, this was easy to do by passing :onclick => remote_function(...) to the checkbox helper. In Rails 3, the remote_* functions are deprecated, so I tried the following workaround: create a form around the checkbox usin...

Requiring authentication file from lib with cucumber

I am trying out Cucumber for the first time and I've come accross an issue. I am try to use RyanB's nifty authentication generator, but it seems I can't use the helper methods when running my Cucumber features. Part of my feature giving me problems: when I am on the new book page # features/step_defin...

Rails 3 x_sendfile on heroku

Hi, Rails 3 allow to send static files directly and more performantly to HTTP clients and bypassing your app server process (as described see http://john.guen.in...) send_file '/path/to.png', :x_sendfile => true, :type => 'image/png' I want to deploy my app on heroku. heroku use Nginx 0.6.32 (see http://docs.heroku.com/aspen). Does...

Testing routes with host constraints via assert_routing in Rails

I have a route which I'm using constraints to check the host and then a route which is essentially the same but without the host restriction (these are really namespaces but to make things simple this example will do): match "/(:page_key)" => "namespace_one/pages#show", :constraints => proc {|env| env['SERVER_NAME'] == 'test.mysite.loc...

How do you scope ActiveRecord associations in Rails 3?

I have a Rails 3 project. With Rails 3 came Arel and the ability to reuse one scope to build another. I am wondering if there is a way to use scopes when defining a relationship (e.g. a "has_many"). I have records which have permission columns. I would like to build a default_scope that takes my permission columns into consideratio...

When -exactly- does the Rails3 application get initialized?

I've been fighting left and right with rails 3 and bundler. There are a few gems out there that don't work properly if the rails application hasn't been loaded yet. factory_girl and shoulda are both examples, even on the rails3 branch. Taking shoulda as an example, when trying to run rake test:units I get the following error: DEPRECATION...

haml with rails3 (git master) and devise: form_for syntax change breaks haml -- suggestions?

i am trying to get haml working with a rails3 project; since i am quite far in the modeling i wanted to go to the haml views now -- seems that the current haml (git master) does not work together with the current rails3 git master because of some syntax changes in rails3 form_for does anyone have more information on the syntax changes?...

searching for a guide how to setup mongo_mapper, devise, haml with rails3

is there a full setup guide for mongo_mapper, haml, rails3 and devise, for the current git (master) branches? a lot of things changed in all of those frameworks/libs lately. i was wondering if somebody has it up and running and can share it on github or give some pointers... ...

Rails 3 and RJS

Hi, I use the rails 3.0.0.beta Is there any new syntax to write RJS, here is an example def remote_create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save # add @photo's thumbnail to last import tag format.js { render :update do |page| page.insert_html :bot...

Normal memory usage in Rails

I'm wondering how much memory usage is normal for a ruby process in a rails application? I really need something to benchmark against. In my dev environment WEBrick a single ruby process uses about 61mb to handle 10 simultaneous requests going non stop. In my prod environment Apache2+Passenger starts 7 ruby processes to handle the same...

Create new Rails project with previous rails version

Hello, The latest version of rails installed on my mac is 3.0.0.beta gem list returns rails (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.2.2, 1.2.6) I want to create a new project using version 2.3.5 So I run: rails _2.3.5_ myProject But it returns the following error $ rails _2.3.5_ photosbackup /Library/Ruby/Site/1.8/rubygems.rb:777:in `r...

mongomapper, rails3 edge: undefined method `to_key' on form_for

when i am trying to get the basic devise examples running with current git versions from rails, mongomapper and devise, i have the following error appearing: undefined method `to_key' for #<Admin:0x23dee04> here is my actual source: 4: = form_for @admin, :url => admins_path do |f| 5: - field_set_tag 'Update my email' do 6: ...

link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?

i am wondering if the basic link_to syntax is completely broken in current rails3 master or if i am doing some wrong syntax here. = link_to "name", nil, :onlick => "alert('Hello world!');" should actually produce an alert on click. very simple. does not work on my rails3 project! (also no error output!) any ideas? for the general lin...

Polymorphic association in reverse

Let's say that I have two models - one called Post and one other called Video. I then have a third model - Comment - that is polymorphically associated to to each of these models. I can then easily do post.comments and video.comments to find comments assosciated to records of these models. All easy so far. But what if I want to go the ...

Nested form child only updates if parent changes.

In this video (10 sec) you can see that the nested attribute is only updated if it's parent model is changed. Using rails 3.0.0.beta and full project is on github. Summary of models and form: class Project < ActiveRecord::Base has_many :tasks accepts_nested_attributes_for :tasks end class Task < ActiveRecord::Base belongs_to :p...

_mask and Rails

So I am trying to get the cancan gem to work with my rails 3 app and I've hit a problem. I tried to copy the code that Ryan Bates (the creator of the gem) used in his screen cast, but I get an error saying that roles_mask is not a method. I figure that the _mask method was removed from Ruby/Rails at some point, and I'm now wondering wh...

Multiple Forms on the Same Page with Rails

So I'm building a rails app for high school students and I've hit a problem when it comes to creating users. I want the students to only be able to create accounts if they select their school and type in their school's password correctly. What is the correct / easiest way of doing this? Should I create a gatekeeper to the user#new acti...