ruby-on-rails3

Rake task to add default data

I have seen some apps that have a few rake tasks included to load data. I am not talking about seed data, I know about db/seeds.rb, instead I am referring to data such as default users and basic records that help me fill my application with something to look at. I don't want to use db:fixtures:load because I don't have any control over...

Rails 3 Redirect using POST

Is it possible to redirect from one controller to another using POST request? redirect_to supports only GET. I found something called "post_via_redirect", but it seems that it was deprecated in Rails 3. ...

Simple Rails 3 CMS Gem/Plugin?

Can anyone recommend a simple, lightweight CMS gem or plugin for Rails 3 that can easily be embedded into an existing app? ...

Rails3: How to recreate test fixtures based on development database schema (newbie)

The situation: I used generate scaffold to set up my objects in a new Rails project. Besides doing some migrations, I also directly edited the MySQL tables by adding and renaming columns etc. Now I can't get tests to run because the automatically-generated fixtures do not correspond to the database schema. Perhaps they're based on the or...

form_for and association in rails

Hi, I have a (rails 3) application that allows users to query for books. I have three models: query, result, book with a has_many :through relation both ways: query has many books through result and book has many queries through results When I enter a query and click OK, I get a form to create a book using the query phrase. I want th...

Rails 3: How to create a new nested resource?

The Getting Started Rails Guide kind of glosses over this part since it doesn't implement the "new" action of the Comments controller. In my application, I have a book model that has many chapters: class Book < ActiveRecord::Base has_many :chapters end class Chapter < ActiveRecord::Base belongs_to :book end In my routes file: re...

Rails 3 Combine Two Variables

I have the following code which I need to update... <% @users.each do |user| %> <tr> <td><%= link_to user.fname, user %></td> </tr> <% end %> I want to learn how to update that so instead of just showing the fname, it shows fname + lname so for a record like James Bond, it shows james bond and links it to the user in Rails. ...

Delete / Destroy issue in rails 3.

My delete/destroy is not working for rails 3. Not for any scaffold or even for new projects. <%= link_to 'Destroy', card, :confirm => 'Are you sure?', :method => :delete %> From this question. Solution is Firefox reinstalation. But mine is also not working in chrome, safari or opera. Html code generated:-- <a href="/categories...

Rails3 + link_to(..., :remote => true) + IE 6/7 does not work

I get this strange error if I use a link_to with the :remote => true parameter in IE 6 and IE 7. IE 8 and all other browsers works just fine: If I commenting out the code for the link (jQuery binding on ajax:success), the error still appears. I don't know how to locate/track this error, because line 1529... does not exists. What is go...

How to avoid Rails scaffold to place model into namespace

Hi guys, Rails 3 scaffold generator places model classes inside namespace. Example: rails generate scaffold admin/portfolio But I want only controllers and views to be placed inside admin namespace. How can I avoid that? Regards, Alexey Zakharov. ...

What does this line of Rails 3 Do?

def self.source_root File.join(File.dirname(__FILE__), 'templates') end ...

Haml render multiple partials in layout

app/views/layouts/shared.html.haml: = render :partial => "shared/head" = yield = render :partial => "shared/footer" app/views/shared/_head.html.haml: !!!XML !!!1.1 %html{"xml:lang" => "pl", :xmlns => "http://www.w3.org/1999/xhtml"} %head %title some title %body .container app/views/shared/index.html.ham...

For Ruby on Rails, how do you switch to a new and empty DB with the same DBMS or a different DBMS?

If no need to migrate the data, it seems that we can just edit database.yml development: adapter: mysql database: myapp_development host: localhost username: root password: encoding: utf8 1) to use a brand new db with 0 data, just change the 3rd line to: database: myapp_development_02 and then do a rake db:create and ra...

Are there 3 forms to invoke production, staging, etc in Ruby on Rails for rails server, rails console, and rake?

The forms I know of are: For Rails 3.0: for rails server: rails server -e production for rails console rails console production for rake rake db:migrate RAILS_ENV=production Is that it? I know for rails runner and rails dbconsole, it is -e production as well. Are there more forms and what are other ones that use -e vs just ...

is ruby on rails (or at least the community) dying?

This is an honest question and I am not trolling. As a newbie to rails I've been search for good rails resources. But I've been noticing many sites that apparently were once popular now being completely abandoned. Some examples: http://www.softiesonrails.com/ - last updated Feb 2010 http://www.therailsway.com/ - last updated Aug 2009...

Upgrade to Rails3 from Rails3.rc2, and forms are blank

Why does the following code work in Rails 3 rc2 but not in Rails 3? <%= form_for :product, Product.new, :url => products_path() do |f| %> <%= f.text_field :name %> <% end %> I have formtastic installed but when I took it out I get the same result. I started this project before Rails3beta 1. Should I have...

Confirmation email from devise on rails3 using gmail not arriving.

I've set the following up. ---------------------- config/environments/development.rb ---------------------- 29 ActionMailer::Base.delivery_method = :smtp 30 ActionMailer::Base.perform_deliveries = true 31 ActionMailer::Base.raise_delivery_errors = true 32 33 ActionMailer::Base.smtp_settings = { 34 :enable_starttls_au...

Why isn't rspec generating specs for controllers?

Created a new app with rails generate new_app -T and ran rails generate rspec:install. $ rails generate controller Test foo bar create app/controllers/test_controller.rb route get "test/bar" route get "test/foo" invoke erb create app/views/test create app/views/test/foo.html.erb crea...

Rail3 - Browser is asking for a username & password when not signed in

Hello, recently my Rails 3 app started asking for a username and password via a browser prompt when loading the home page and not signed in... <%= javascript_include_tag :all, :cache => true %> I was able to determine that it's the line above causing the issue. If I remove that it doesn't happen. Ideas? Have you seen this before ? T...

Rails 3 - including JavaScript on a View?

Hello, here's what I'm trying to do right.... When a user signs in and is redirect to the landing page, I want to run a bit of jquery ajax to grab and inject some content. I originally had it in my application.js file but the problem with that is that the code is there for user's that aren't logged in, which means I have to add logic to...