ruby-on-rails

Routing Error - No route matches "/" ?

Hello, new to Ruby on Rails, trying to configure the home page of my application. I don't know what I'm doing wrong, or how to configure the :home controller, but I get this error with this routes.rb file. Routing Error - No route matches "/" Here's routes.rb SchoolCMS::Application.routes.draw do devise_for :teachers, :admin res...

How to define a route in Ruby on Rails

I'm trying to define a route in routes.rb and I can't do anything from this Ruby on Rails routing guide that will let this error pass. No route matches {:controller=>"devise/home"} Here's my routes.rb source. SchoolCMS::Application.routes.draw do root :to => "home#index" devise_for :teachers, :admin resources :home, :only => ...

Ajax pagination like Twitter

Is there any plugin/gem or an easy way for accomplish a pagination functionality like Twitter? This means, showing a "More" button that shows more posts (for example) below once it's clicked, using Ajax. If there's any easy way for modifying something from will_paginate plugin, that would be useful too. ...

authlogic require user

I use authlogic for authentication and certain actions require a logged in user, which is controlled via a before_filter like the following. I also use friendly_id on the User model and internally everything there is a look up on the User model there are queries to the friendly_id slug table too. This results in at least 3 queries for ce...

Multiple ajax calls are being executed when clicking on a page from will_paginate plugin

I'm trying Ajax Will Paginate plugin. For further info click here. My view's code is: <h4>Top Ten</h4> <div id="top_ten_results"> <p> <table border="0"> <% unless @top_ten_posts.nil? %> <% @top_ten_posts.each do |p| %> <tr> <td><%= link_to p.title, p %></td> </tr> <tr> ...

Undefined method/NoMethodError in Rails 3

So I am doing a lynda.com Rails essential training tutorial, and I am getting an error that the video tutorial does not. I assume this has to do with the different versions of Ruby & Rails that I am using (the latest as of today) as opposed to the ones they used when this was recorded (I think in 2007). This is what my controller looks ...

Restrict embedded docs in query with Mongoid

I'm writing a quick little money tracking rails app for fun that allows a user to enter their daily bills. I have a user embeds_many :bills. I'm using Devise for auth. Here's my question. When I fetch current_user each time from my session_id, it's going to pull in my whole user and its embedded docs correct? So as bills add up, my ...

How to show a login modal in Rails if a user tries to access an authorized section

How would you implement a modal window saying "In order you to access this area you have to be logged in.." in combination with a login form below it every time a user tries to access authorized content. I'm using Rails 3, Devise and CanCan. My first thoughts were do put it somewhere in the application_controller.rb: # application_cont...

Rails application runs from terminal but not from Netbeans - missing gem error

Hello! Been trying to get my project up and running on an Ubuntu Virtual Box machine. Everything works fine from the terminal, but when I try to run my application from Netbeans I get the following error: => Booting WEBrick => Rails 2.3.5 application starting on http://0.0.0.0:3000 /home/soroush/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails...

Rails ActionController::InvalidAuthenticityToken All browsers

Hi, I'm having an issue with one user. No matter what he does he ends up getting throwing an ActionController::InvalidAuthenticityToken error. I have tried having him clear his browser's cache, cookies, etc. He gets this using both FireFox and Internet Explorer. I'm at a loss as to why this would be occurring for just him. Everythin...

Optimizing use of database queries

Is it faster to do a single database query that finds all the results you need for a page, then do several loops through it with if/else statements to extract what you want to show in each section, or to do several database queries selecting the exact data you require and then just loop through each one separately? For instance: @compl...

Carrying along params in a form

Let's say I have a Students table on my main page, with Country, Name, Age columns. Suppose I want to have a dropdown box that lets users filter students by country, and also a search box that lets users search for students with a particular name. I know how to create the country dropdown filter by itself: <% form_tag('/students', :met...

Help with JQuery autocomplete in rails3

Hello. I'm having difficulty setting up JQuery Autocomplete with Rails3. I don't get any errors, it just behaves like regular text box. Here is what I have done: First I installed autocomplete as explained here: http://github.com/crowdint/rails3-jquery-autocomplete#readme I have a model class which contains the model which will be ...

Are there any free tools that will allow me to view my RoR sqlite3 DBs?

Are there any free GUI tools that will allow me to view the contents of my RoR sqlite3 DBs? ...

Character set ISO-8859-1 displaying improperly

My default character encoding is Western (ISO latin 1, ISO-8859-1). I am using this code to change the character set: <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> My website only displays properly when I click on "Text Encoding" then "Western (ISO latin 1)" in the Safari view menu. Even when set on defau...

What is the Rails3 equivalent of start_form_tag?

Newbie here...I am just going through, what is clearly, an old rails tutorial. To create a form they have the following code: <%= start_form_tag(:action => 'create')%> <%= text_field(:album, :title) %><br /> <%= text_field(:album, :artist) %><br /> <%= text_field(:album, :genre) %><br /> <%= datetime_s...

activerecord query as map reduce in mongodb

I would like to know how I can reproduce the following query as map reduce or any juice function from MongoMapper or MongoID: Event.find(:all,:select=>'events.company,SUM(price) as total_price', :group=> 'company',:order => ' total_price DESC, created_at DESC') ...

Rails misbehaving wrt Postgres SERIAL NOT NULL column

I am developing a (currently) Rails 2.3.x application with a PostgreSQL 8.4 database backend. In my Rails application, I have a model corresponding to a database table that has two columns of datatype SERIAL and set as NOT NULL. I have one of these columns set as the primary key in both Rails and as a PostgreSQL constraint. Table defin...

How to install Diaspora in Windows?

I am trying to install Diaspora. When I bundle install in Windows, I encounter some problems which include Fetching http://github.com/BadMinus/devise.git C:/Ruby Installation/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.2/lib/bundler/ \ source.rb:550:in ``': No such file or directory - git clone \ "http://github.com/BadMinus/devise.git" \...

problems with rails ajax call

I'm fairly new to rails so forgive me if I'm making some dumb mistake here. I'm trying to make an ajax call with link_to, and respond to a js.erb template. It isn't going so well. The link renders correctly: <a href="/show" data-method="post" data-remote="true" rel="nofollow">Click</a> The barebones show action: def show respond_t...