ruby-on-rails

Rails AJAX Image Swap

I'm trying to make an AJAX call in Rails to swap images on a page. The page has a big div that is initially blank, along with a table with several entries. One of the columns in this table contains the path for an image, and what I am trying to do is on user click, swap this image into the div. I was hoping to have a controller variab...

rails fresh_when/stale? usage

In my post_index action, I generate different kinds of "@posts" like.. def index case params[:listing_type] when "all" @posts = get_all_post_from_memcached when "most_popular" @posts = get_all_most_popular_from_memcached respond_to do |format| format.ht...

Rails: how to create a default route for specific object

I have a User class and map.resources :users in my routes. If I create a link link_to @user.name, @user It will somehow automatically create a link to /users/3 where 3 is an ID of the user. What if I want to create more userfriendly links and identify users not by IDs but by their usernames. So path would look like /users/some_user...

typing 'rails console' doesn't start?

I typed this: >rails console and got this: Usage: rails new APP_PATH [options] Options: [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 .. .. . I'm...

will_paginate and named_routes

sorry for my english... I have some problems using will_paginate and named routes, here is some code (my site is in spanish language): routes.rb map.animals '/animales/:scope/:id', :controller => :categories, :action => :show with these routes I generate urls like: www.domain.com/animales/mamiferos/perros but, when pages links ar...

Creating Twitter-style routes with Rails3

How can I make Twitter-style routes with Rails3? I've tried the following: match ':username', :controller => "users", :action => "show" match ':username/:controller(/:action(/:id))', :path_prefix => '/:username' EDIT After some more digging through the docs, I did this and it seems to work: scope '/:username' do resources :clubs ...

How to pull plugin from github on heroku?

Gemfile: ... gem 'paperclip', :git => '[email protected]:mdrozdziel/paperclip.git' ... While pushing the app I get the following error. The repo I am linking to is public. Fetching [email protected]:mdrozdziel/paperclip.git Failed to add the host to the list of known hosts (/home/group_home/.ssh/known_hosts). Permission denied (publi...

Links using ip address and port , not the domain name.

Hello, May I ask why does the links in my rails app uses our server's ip address and port instead of the domain name? For example, javascript and stylesheet tags : <link href="http://xxx.xxx.xxx.xxx:12001/stylesheets/shared/tables.css?1282918370" media="screen" rel="stylesheet" type="text/css" /> I obscured the IP a bit but ...

Reformat (crazy) strings with RegExp

My application fetches information from an API. Unfortunately their data isn't very pretty. This is what the strings can look like: 2 2:30 10.00 2 am 3:30 pm 10:00pm est 10:00pm PT/EST 10:00pm (Central) 10:00, 11:00 & 12:00 I mean, they can pretty much be anything :) I need the format to be 12:00 (HH:MM) ! Here is what I've got so ...

Ruby on rails hosting

First Hello, and then yearh i know Heroku! But they somehow just dosen't fit my interest, i want to have an email service. Well that's fine with heroku if you insert your credit card informations.. Well ya, no thank you.. So is there an alternative to Heroku? Or is it just imposible? ohh.. by the way, i need crons, email and rails3 su...

Cleaning up the jQuery in rails

I have a rails application and I have all the jQuery scattered out in alot of different views and this is really ugly.I really want the jQuery in one place but when i take some of the jQuery code and move it to the application.js file the jQuery doesnt work or is maybe included last....I really dont know the issue. Can i have some help o...

Where do i put this jQuery in a rails application

I have this chunk on jQuery and currently its living in my index.html.erb and it works well. I have alot of snippets like this that i want to move out of the views and into some other file or files to clean them up. Here is my snippet $("#request_artist").autocomplete({ source: function(req, add){ $.getJSON('<%= ...

annotate command not working, added it to my gemfile

My gem file looks like: group :development, :test do gem 'rspec-rails' gem 'annotate-models', '1.0.4' end I ran 'bundle install' and it installed the annotate-models bundle. If I type: annotate I get a command not found error. If I type: bundle show annotate I get a 'could not find gem annotate in the current bundle. If I...

Do I really need to have an ID to a child table in rails using active records ?

I have a user model (sql table) that has_one : profile. profiles have user_id to refer to an user object. Do i really need to have profile_id column ? What are the advantages and disadvantages ? I guess one advantage will be the size of the table that will be 1 collumn smaller. What are the disadvantages ? ...

Why would running a Rails app as a WEBrick server work, but installing it as a Mongrel service would not?

Yet another newbie RoR question from me. I started banging my head against a wall last night when I simply could not get my Rails app to display in my browser after installing it as a Mongrel service. I installed it using a command like this (from the app's root directory): mongrel_rails service::install -N MyAppName -e development -...

activerecord find conditions for associated models

so i havent found much documentation about using conditions on activerecord find methods for associated models, but i have found a variety of examples. although none of them seem to be working for me. user has_one avatar avatar belongs_to user Avatar.find(:all, :include => :user, :conditions => {:user => {:login => 'admin'}}) return...

I deleted a rails gem in the wrong way - what should I do?

So I installed rspec 2.0 beta 22 and then I deleted the folder in the library folder on my mac (I know i'm an idiot). Now I can't reinstall or uninstall. HELP!! Thanks ...

Heroku, Rails 3 and sqlite3

I experience the same scenario as described here http://www.ruby-forum.com/topic/217022 when I try to deploy my Rails 3 app to Heroku and sqlite3 is defined in the gems file. /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require': no such file to load -- sqlite3 (LoadError) Any clue why this is?...

Does paperclip work with SimplyStored?

Rails 3.0.0, paperclip 2.3.3, simplystored 0.3.6. I'm using simplystored so i can use couchdb, but i am thinking that simplystored doesn't work with paperclip. I've tried using paperclip as a gem [via bundler] as well as a plugin, and I get the same error regardless: undefined method `has_attached_file' for Video:Class. Any way to g...

assigns_to doesn't work for Rails 3 Shoulda on Ubuntu

Hi I'm using Rails3 with rspec and shoulda. I have the below spec describe PagesController, "on GET to show while logged off" do before(:each) do @site = Factory.create(:site) @site.domains << Factory.create(:domain) @site.save! @site.pages << Factory.create(:page) @site.menus << Factory.create(:menu, {:site=>@si...