ruby-on-rails3

Rails 3 renders Haml file as Html

Following the guide at http://github.com/fortuity/rails3-mongoid-devise I've managed to setup Rails3 with Haml, Devise, and Mongoid. (As a side-note, the guide is really detailed; recommended reading for new Rails users!) Only problem is I can't get Rails to render my Haml views: Started GET "/" for 127.0.0.1 at 2010-07-01 14:40:23 +02...

Rails3 rails console crashes throwing error

Hi, I am trying Rails 3 and I am using RVM to manage the ruby versions. Using RVM I had installed ruby versions 1.8.7, 1.9.1 and 1.9.2. When I do "rails console" I am getting the following error and console isn't starting: /home/syed/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load...

Rails3: Base#after_update has been deprecated

I see the warning: DEPRECATION WARNING: Base#after_update has been deprecated, please use Base.after_update :method instead. (called from <class:City> at /home/petrushka/webdev/my_app/app/models/city.rb:4) What should I write instead of def after_update .... end ...

Rails - Application layout with SQL?

Hello, all my fellow coders! I've got a problem ohh chok!.. :P Now my problem i that i'm trying to make a design for a bigger site, it's going good. Until i should make the content/news slider. It should take data from multiple tables and returning to the application.html.erb. So it is take reviews and announcements just the latest 5 ...

Problem with a query with associations and "strange" select

Quick question: >> Group.first.resources.joins(:tags).group("tags.id").select("tags.id, count(*)") => [#<Resource id: 1>, #<Resource id: 2>, #<Resource id: 3>, #<Resource id: 4>, #<Resource id: 5>] This results in the following (correct) query: "SELECT tags.id, count(*) FROM "resources" INNER JOIN "taggings" ON "resources"."id" = "ta...

Plugin/Gem to get Rails 3 style UJS in Rails 2.3.x?

I have a new application starting that's using Rails 2.3.8 for stability concerns and gem compatibility, however we'd like to begin being conscious of Unobtrusive JavaScript by implementing the Rails 3 style UJS in this application. Is there any existing plugin/gem that backports this feature? We are currently using the jrails gem to s...

rails 3 or rails 2.3.8

i heard rails 3 almost ready to be released from beta, mean stable version. but of course the real date still unknow. so i wanna ask ror rock developer. do u think me should learn and use rails 3 RC ver. or use rails 2.3.8??? if i now use RC version will it be hard to upgrade to stable rails 3 version? can anyone rock developer guide m...

Rails3: warning: toplevel constant ApplicationController referenced by ...

Everytime i get a warning: app/controllers/agency/agencies_controller.rb:1: warning: toplevel constant ApplicationController referenced by Agency::ApplicationController My agencies_controller.rb: class Agency::AgenciesController < Agency::ApplicationController def index ... end ... end And Agency::ApplicationController...

get Rails3 app name in a template that generates a rails app?

I have a template that generates a rails app. The problem is that in my template scenario I substitute some files, like environment.rb, that need to know rails app name to run things like AppName::Application.initialize!. I could get the app name from the command line arguments, but that's not always possible, since a user could do that:...

what is the equivalent in rails3 routes?

Hi, I have used this route in rails 2.3.5 - basically, I wanted to be able to parametrize my controller that I send to the named route. do_action "do_action/:controller" , :action => "do_action" what is the equivalent of this in rails3 routes? This doesn't work: match "do_action/:controller" , :to => ":controller#do_action", :as => ...

ActiveRecord object serialization and deserialization to the database

Hello, I would like to deserialize an serialized object. So it's possible to process such as (with JSON): >> l = Yea.create(:title => "foo bar") => #<Yea id: 3, title: "foo bar", created_at: "2010-07-05 21:44:54", updated_at: "2010-07-05 21:44:54"> >> j = l.to_json => "{\"yea\":{\"created_at\":\"2010-07-05T21:44:54Z\",\"title\":\"foo ...

Rails 3: how to load files in /lib?

I'm new to rails and making some sort of noob mistake: I frequently need to count the number of lines in a file, so I'm trying to monkey patch class File like this: class File def self.line_count( filename ) %x{wc -l #{filename}}.split.first.to_i end end I saved this to /lib/file_util.rb. I thought that this was supposed to...

Rails Beta4 with Ruby 1.9 setter method mass assignment

I have a setter method (below) that works perfectly under Ruby 1.8 but broke when I moved to 1.9. In the controller I could create a task with: @task = Task.new(params[:task]) under 1.9 I have to do @task = Task.new(params[:task]) @task.due_at = params[:task][:due_at] Is there something about mass assignment I'm missing? Thanks! c...

What is the replacement for ActionController::Base.relative_url_root?

I am porting a 2.x rails app to rails3; we'll call it foo-app. Foo-app is one section of a larger rails app and lives at main_rails_app.com/foo-app. Previously we just set up the following in our foo-app production config to ensure that our foo-app routes worked properly: ActionController::Base.relative_url_root = "/foo-app" However, ...

uninitialized constant ActiveSupport::Cache::MemCacheStore::MemCache

I got this error when I start my project with memcache (gem) and rails 3.0.0beta Here's the full trace: /Users/netbe/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta4/lib/active_support/cache/mem_cache_store.rb:39:in `build_mem_cache': uninitialized constant ActiveSupport::Cache::MemCacheStore::MemCache (NameError) from /Use...

Rails3 routing: Resource with namespace

Hi! Is it possible to define a namespace parameter when defining my routes, like this: resource :account, :namespace => :account do resources :comments end So /account/comment calls Account::CommentsController instead of just CommentsController. Just as a note, the :namespace-option above does NOT seem to work. I can of course ...

no such file to load -- rspec/autorun (LoadError)

attempting to use rspec2, rails3, and autotest. When running autotest I get stuck with the following: loading autotest/rails_rspec2 style: RailsRspec2 -------------------------------------------------------------------------------- ... ...bin/rspec:2:in `require': no such file to load -- rspec/autorun (LoadError) Looks like a path ...

Requiring gem in Rails 3 Controller failing with "Constant Missing"

I've seen this asked a few times in other threads, but none of the answers seem to apply. Environment: Rails 3 amazon/ecs gem from jugend. The lone file is here: http://github.com/jugend/amazon-ecs/blob/master/lib/amazon/ecs.rb my gemfile has: gem 'amazon-ecs', :git => 'git://github.com/jugend/amazon-ecs.git' Everything works in ir...

How do I add custom javascript to my rails3 views?

What is the best way to add JavaScript to my Rails3 views? I would like to be able to do some processing in a controller, then craft some JavaScript based on the result and put the resulting JavaScript in a view. For example, I would like to get a series of lat/lng points from a database and create markers on a Google Map. The map i...

Problem creating more than one Rails app using MongoDB

I properly installed MongoDB and got it running on my OSX. The first app I created using MongDB and Rails3 was titled 'todo". Per the instructions on railscasts, I created a file (config/initilializers/ mongo.rb) and added this line: MongoMapper.database = "todo- #{Rails.env}" Presumably, this created the files that appeared in my ...