ruby-on-rails3

In Rails, I thought once the "Foo.all" is executed, then "models/foo.rb" is loaded?

In Rails, if I create a scaffold foo, and do rake db:migrate, then now app/models/foo.rb is created. So if I go to script/console (or rails console for Rails 3) and type $".grep /foo/i it is empty. $" is the loaded files. So foo.rb is not loaded yet. Now I do a Foo.all, and foo.rb should be loaded now. But when I repeat ...

Why is this basic Rails 3 route not working?

I've just upgraded to Rails 3, and decided to take it for a whirl with a dummy/sandbox app. The strange thing is I can't seem to get any routes to work! Here's my problem: [cobychapple@shiva:Dev]$rails new TestApp create create README create Rakefile ... [cobychapple@shiva:Dev]$cd TestApp/ [cobychapple@shiva...

Going into any Rails project folder, is there a reliable way to tell which version of Rails it is using and created with??

that is, to tell the current Rails version it should use, and also to find out what version of Rails started this project. ...

Test the render method in a controller with RSpec

I am trying to test the render method in a controller with RSpec (2.x). Here the code in my controller: respond_to do |format| format.html # index.html.erb format.json { render :json => @entities, :include => :properties, :overview => options[:overview] } end And here the test I try in my spec file: controller.should_receive(:r...

Authlogic + Rails3 - undefined method `Login' for nil:NilClass

Im new to Rails, and decided to start of with Rails3. After a lot of searching ive managed to get a little bit of Authlogic working. I'm able to register a user, login & logout. Now, I would like to add more features, get more of authlogic working. I'm using Railscast EP 160 as my reference. Portions of the code found on the tutorial t...

counter_cache in single table inheritance

I am wondering if the counter_cache would work in single table inheritance. For these models: class User has_many :questions end class Question belongs_to :user, :counter_cache => true end class SimpleQuestion < Question end class ComplexQuestion < Question end So will the following counters work? create_table(:users) do |t| ...

Managing restful resources in Rails 3

I am trying to convert my Rails 2 app to Rails 3, but I can't delete any resources using my old Rails 2 code. To be precise I am trying to delete a resource, using this link: <%= link_to image_tag("misc/delete.png"), @book, :confirm => 'Are you sure?', :method => :delete %> And yet it doesn't work at all! It just behaves as if the :co...

Filter by count of children using Rails 3

I'd like to select posts that have one or more comments using Rails 3 and a single query. I'm trying something like this: Post.includes(:comments).where('count(comments.id)>0') However I get this error: ActiveRecord::StatementInvalid: PGError: ERROR: aggregates not allowed in WHERE clause I've googled this and similar approaches,...

Rails/facebox_render - Ajax is not defined (facebox's always loading...)

Hi, I tried to make a simple test with facebox_render and rails 3. Here are my steps: 1.) Installed Jquery 1.4.2 (Jrails) 2.) Installed the plugin rails plugin install git://github.com/ihower/facebox_render.git 3.) and added the following lines: in my application.html.erb <head> <title><%= yield(:title) || "Untitled" %></title>...

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

Same question, but solution did not work:, I've tried several versions of rspec: http://stackoverflow.com/questions/3517724/rspec-is-giving-an-error-with-my-layout-links-from-the-rails-tutorial-failure-e dpalacio:sample_app dpalacio$ rspec -v 2.0.0.beta.18 dpalacio:sample_app dpalacio$ rspec spec/ controllers/ factories.rb models/...

Rails 3: DataMapper instead of ActiveRecord

After all the hussle about Rails 3, can I, after all, painlessly use DataMapper without almost changing my ActiveRecord code so that I could run my Rails at GAE without any bother? ...

Rails 3 - w jQuery - Global Loading Event?

Hello, is there a Rails 3 jQuery global loading event? I'd like to display a LOADING banner anytime jQuery is AJAX loading... and remove it when it's done... Ideas? Thanks ...

Ruby On Rails 3 submit form AJAX update results in div

I am stuck; I did a search and I can't find a pointer on how to get this project to work. I have a form on my index.html.erb as: <html> <head> <title>Ajax List Demo</title> <h1>Listing posts</h1> <%= javascript_include_tag "prototype" %> </head> <body> <h3>Add to list using Ajax</h3> <% form_tag ( :remote=>tru...

Rails 3 - Need help understanding how to QUERY with a WHERE IN (XXXXX)

Howdy. I want to build a rails query like the following. And would like to learn how so I can do it again on my own. Pseudo Code: @usersprojects = ?? Do I get record or just objects here? not sure? SELECT * FROM audit_log WHERE project_id IN (@usersprojects) IN the where IN () do I some how tell Rails to use the record.id? thank y...

Rails - Understanding how to Query An Objectin Rails 3

Hello, if I have the following: @projects = Permission.where(["user_id >= ?", 21]) Results In: [#<Permission id: 59, project_id: 13, user_id: 21>, #<Permission id: 59, project_id: 13, user_id: 21>] I then what to use those project_id 's to QUERY as follows: AuditLog.where({ :project_id => @projects }).limit(10) But this errors? ...

How can I customize rails3 validation error?

If I have a text input name 'email', and if I set :message => 'Your email is wrong kind' the validation error message will have something like 'Email Your email is wrong kind.' I am wondering if there is any way to remove that orginal input name (in above case, its Email) from the validation error output in rails3. ...

Process.fork in Rails controller

We're doing some prototyping of a new app and noticed that one of the actions were taking forever to load (80-120 seconds). As a lot of the processing doesn't need to happen on page load (we can request the data via Ajax later), I thought of using Process.fork to allow the page to return immediately, while the processing still happening ...

How can I use content_for to put something in :yield

I am in ruby 1.9.2, rails3. So My website has some structures, and I want to put menu in a middle of my webpage. I am doing something like (within application.html.erb file) blahblahblah <div id="menu"> <%= yield :menu %> <div> blahblhablah I have a file menu.html.erb which has menu structure for the site. What can I do if I wan...

Drag and Drop in rails 3

I am working on the drag and drop feature. I had a working code for that feature. Its written in rails 2.3.5. When I am shifted to rails 3, I used the same code. Actually drag and drop is working, but the position automatically changes in rails 3. In 2.3.5, position will not change. <% for item in section_menu_items do %> <li id='<%...

What's the best way to make Rails 3 / Active Record associations for classes of a simple point of sale program?

I have 5 classes that are part of a point of sales program: Customer, Technician, Order, Ticket, Service Each Order has one customer and many tickets. Each Ticket has on technician and many services. How should I make the associations so that I can do the following lookup: customer.order.find_by_date(10/20/2010).service.technic...