ruby-on-rails3

Best way to handle 404 in Rails3 controllers with a DataMapper get

It's very simple, I want to handle a normal [show] request with a call to DataMapper like I did in Merb. With ActiveRecord I could have done this: class PostsController def show @post = Post.get(params[:id]) @comments = @post.comments unless @post.nil? end end and it handles the 404 by catching the resource's exceptions. ...

Rails 3 content_for issues

Hi, I've recently built a fairly deep nested form using http:// github.com/timriley/complex-form-examples for guidance. The form partial uses the following in order to render new fields when a link is clicked: <%= yield :warehouses_fields_template %> <%= yield :ratgrades_fields_template %> The content for these is generated i...

Rails3: Unit testing a library doesn't load the fixtures

I added a unit test manually to test a library I'm building. I have some fixtures which are tested in their corresponding models without any issues. The test case inherits from ActiveSupport::TestCase which runs fixtures :all. require 'test_helper' require 'mylib' class MyLibTest < ActiveSupport::TestCase @user = User.find(1) te...

user subscription and authenticity_token need CAPTCHA ?

I am currently developing a user subscription module and I would like to know if I need to use captcha in rails 3 because authenticity_token sound good. Thanks ...

Rspec is giving an error with my layout links from the rails tutorial: "Failure/Error: Unable to find matching line from backtrace"

Hi, I'm following the rails tutorial here: http://railstutorial.org/chapters/filling-in-the-layout#top When i run "rspec spec/", i get a bunch of errors that look like this: 1) LayoutLinks should have a Home page at '/' Failure/Error: Unable to find matching line from backtrace stack level too deep # C:/Ruby19/lib/ruby/1.9....

facebook OpanGraph API on Rails (FBGraph)

I am trying to use FBGraph to let my app publish messages on the users wall. However, all of the APIs are kind of foreign to me and I am just trying to change things and see what happens. Right now, I am getting this error message { "error": { "type": "OAuthException", "message": "Invalid redirect_uri: Given URL is not a...

How should these rails paths look like?

my routes should look like this: >rake routes GET /categories/:category_id/articles(.:format) {:controller=>"articles", :action=>"index"} category_articles POST /categories/:category_id/articles(.:format) {:controller=>"articles", :action=>"create"} new_category_article GET /cate...

Rails3 has_many :through and foreign_key not work in set :class_name

Hi, all I need find friends activities: SELECT `activities`.* FROM `activities` INNER JOIN `friendships` ON `activities`.user_id = `friendships`.friend_id WHERE ((`friendships`.user_id = 1)) My add this code to User Model: has_many :friends_activities, :class_name => 'Activity', :through => :friendships, ...

Rails 3 and unobtrusive javascript

Hi guys, I've got a problem with linking unobtrusive js file with view. I've got view named index.html.erb ... <div id="fooBar">say bye!</div> ... Also I've got js file index.js.erb $("#fooBar").html("say hello!") Currently I get say bye message, because javascript file are not executed. What I'm doing wrong? It seems to me th...

[rails3] rewrite complicated query with union in arel?

I have the following models class Courier < ActiveRecord::Base has_many :coverages end class Coverage < ActiveRecord::Base belongs_to :courier belongs_to :country_code end class CountryCode < ActiveRecord::Base end and then i have the following query: # could i translate this into cleaner arel? result = Courier.find_by_...

rails 3 - fcgi_handler and dispatcher missing

Im trying to update a 1&1 server to run rails 3 with apache and fastcgi. Has anyone done this yet? I the dispatch.fcgi file I have: require 'fcgi_handler' but apparently rails 3 does not have this file any more. ...

Exception Notification Gem and Rails 3

I'm trying to get this up and running, but I see "uninitialized constant ExceptionNotifier" whenever I start my server. http://github.com/rails/exception_notification In my Gemfile I have gem "exception_notification", :git => "http://github.com/rails/exception_notification.git", :branch => "master" I've tried putting the configurati...

twitter_oauth is giving me Invalid / expired Token

I am using twitter_oauth gem for Rails to implement Twitter posting feature. I currently got my app to ask the user for Deny/Allow access of my app. However, after that when I try to publish, nothing happens. And, as I debug, I got the following error request: /1/statuses/update.json error: Invalid / expired Token I believe the consum...

Installed ruby-1.9 (rvm) and rails 3, mongrel or thin uses system ruby

I am using rvm rvm list rvm rubies jruby-1.5.0 [ i386-java ] jruby-1.5.1 [ i386-java ] ruby-1.8.7-p299 [ i386 ] => ruby-1.9.2-p0 [ i386 ] with: rails -v Rails 3.0.0.rc ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux] However, when starting rails (with either webrick or thin), the ruby interpretor used is ru...

Should I use Ruby 1.9.2 with my new web app?

Starting a new web app with Rails 3. I'm still relatively new to web development and have really enjoyed all the internet resources available to me while working in Ruby 1.8.7 and Rails 2.3.5. Any advice against using Ruby 1.9.2 on my new project? ...

Rails 3 routing - passing params from routes.rb

In rails 2.3.5 you could do something like this inside the routes.rb file: map.root :controller => "pages", :action => "show", :id => 3 In rails 3 I haven't found any way to pass a specific parameter (like in rails 2.3.5 with :id => 3). I know I can handle it from the controller and have the same result (which I did), but I was wond...

How to turn off generators for RSpec 2 in Rails 3?

I installed the current RSpec 2 Beta under Rails 3 RC as mentioned on the GitHub page (and several blogs). Everything works fine, but I am not able to turn off specific generators like advised on some blogs. Here is what I do in ./config/application.rb: config.generators do |g| g.test_framework :rspec, :fixtures => false, :views => f...

:method => 'delete' in link_to doesn't seem to work in Rails 3?

I have code like this in a Rails 3 app I'm working on <% @positions.each do |position| %> <tr class="<%= cycle("", "alternate") %>"> <td><%= position.name %></td> <td class="actions"> <%=link_to 'edit', edit_position_path(position), :class => 'edit' %> | <%=link_to 'delete', position_path...

redirect_to object record with a field beside the ID property

This is likely something easy to accomplish, but I'm having difficulty even articulating clearly, leading me to get all sorts of semi-germaine, but not quite what I'm after posts on SO when searching. I have a resource, we'll just use User as a simple to discuss use case. I desire SEO friendly URLs, so instead of ~/users/:id, we have ~...

Add initialization step to Rails 3 boot process only in server mode

According to http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html, if I write a Rails 3 plugin and I want to hook into the initialization process, I write class MyRailtie < Rails::Railtie initializer "my_railtie.configure_rails_initialization" do # some initialization behavior end end However, this initializer appears to ...