ruby-on-rails

How do I do paging of records with ruby on rails?

I want to do paging of lists of data with ruby on rails. Basically, I want to show only 20 records at a time, with next and back buttons. It would be nice, but not required, to show links for the page numbers. Something like this would be nice: << Previous 1 2 3 4 5 ... Next >> Is there a built in way to do this in ruby on rails...

Custom color schemes for user logged in profiles

I this is a really general question, but what would be the best way to go about allowing users to customize the color of their logged in profile? Should I put css the inline? Nnd can I store the color values in something like a the session so they do not have to be looked up everytime? ...

How to do "Due in X days/time" for a todo app in rails?

Say I have a todo app that has title and due_date fields. How do I say "Due in X days?" If a certain todo is due on Dec 29, it should say due in 2 days, X hours. I suppose it was to do something with Time.now. I understand there's a <%= distance_of_time_in_words_to_now%> is there an opposite to that? Thanks ...

Do we use Rails ActiveRecord as a Hybrid Structure, i.e. Data Structure+Object ?

I have been using Rails for over 4 years so obviously I like Rails and like doing things the Rails Way and sometimes I unknowingly fall to the dark side. I recently picked up Clean Code by Uncle Bob. I am on Chapter 6 and a bit confused whether we as rails developers break the very fundamental rule of OO design, i.e. Law of Demeter or e...

Why would I have to restart rails every time to test a 404.html page here?

Hi there, I'm trying to work out why when working on a 404 page on a rails app I'm working, the only way to see changes I've made to the html on the page is to physically restart the webserver with a ctrl-C followed by a call to script/server. As far as I can tell, I can't see anything particularly wrong with the development.rb config ...

Rails: exclude anything from version control?

When you place a Rails project under version control, do you exclude anything? Log files, for example? ...

Rails compass libraries

I have installed compass via rubygems doug:aggio davide$ sudo gem list compass * LOCAL GEMS * compass (0.10.0.pre2) compass-colors (0.3.1) * LOCAL GEMS * fancy-buttons (0.3.7) * LOCAL GEMS * haml (2.2.16, 2.2.14, 2.2.13, 2.2.10, 2.2.9, 2.2.6, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.0.10, 2.0.9) haml-edge (2.3.100, 2.3.97, 2.3.83, 2.3...

How to learn Ruby on Rails (RoR)?

I found that Ruby on Rails (RoR) is very convenient, because it have some many helpers and special tags to reduce my work load, but I find this is difficult to understand the symbol in RoR. It seems that RoR includes some special syntax / symbols. And the API is not easy to read like Java. How can I get a better understanding of this spe...

rails, REST and context

hi all. I'm developing my latest rails app using a REST style. I've hit a bit of a problem with context however. Let's say I have an Item model. I'm using edit/update to handle the processing, but the model is edited differently depending on the context. sometimes all I'm doing is changing a 'status' attribute and don't need to show the...

Rails migrations for postgreSQL schemas

I'm working on a multi-tenant rails application using PostgreSQL schemas for different clients. Rails migrations don't work with multiple schemas out of the box, so I made the following rake task to migrate all schemas and it seems to work. My question is if others have implemented better and more elegant solutions. I would also be reall...

Nokogiri screen-scrapes a large set of data. How do I save all of the data in Rails?

The following code screen-scrapes fishersci.com for 3 pieces of information: The product name, The product URL and the catalog number and saves the data into 3 table items rec_item, rec_url and rec_cat respectively. # lib/tasks/inventory_courses_new_item.rake task :fetch_new_courses => :environment do require 'nokogiri' require 'o...

recommendation of a Non-relational database with Ruby on Rails?

I want to start playing with non-relational database, but want something that is popularly used with Rails. I'm considering the ones in the article and leaning towards Voldemort or CouchDB: http://www.ithighlight.com/2009/07/list-of-companies-powered-by-non-relational-database/ Any recommendations? ...

Only Allow Video Embed Codes (Rails)

I was wondering if anyone knew of a way to only allow embed codes like ones from youtube, vimeo, blip.tv, etc. into a form field? I have a form on my site that allow users to embed a video but I only want them to add the embed code html and nothing else dangerous like JS or additional html. Is there any tool out there that can do this or...

Why does Rails 2.0.2 Load?

Why does this happen? ruby script/console Loading development environment (Rails 2.0.2) >> exit jay-z-mac-pro:justinz$ rails -v Rails 2.3.3 ...

"Search and add to list" with jQuery and Rails

Hi, I'm building my second serious Rails application and I want to play around with some ajax aswell. What I would like to achieve is something like this: Search for a user and click it to add him -Searchfield -Live feedback with clickable users Users added to your project: John Doe Bob Lisa So when a user is clicked, a div or...

How to create search engine friendly url for rails models?

I looked into this plugin called acts_as_permalinkable at github and found it to be useful. Do you know of any other plugin that generates search engine friendly urls for ruby on rails models in a better way? ...

How can I get a list of all available models from within a running Rails project, to say, from a console?

The method to walk through apps/models and look into each file for classes is not what I'm looking for ...

delayed_job - Performs not up to date code?

I'm using delayed_job (tried both tobi's and collective_idea's) on site5.com shared hosting, with passenger as rails environment. I managed to make jobs done. However, it seems the plugin ignores any changes in a job class source code after first run. I have restarted the server on every change (touch tmp/restart.txt) but it still ignore...

Ruby on Rails: Can I route a request directly to a view?

I have an admin section that has a sub-directory of the controllers directory. I.e., the directory app/controllers/admin/ holds a set of files, each containing a controller for handling a separate portion of the admin section. Now, I want to create a very simple ''admin homepage'' that just says something a la "welcome to the admin sect...

Default namespace for polymorphic url_for

In my application I have a namespaced admin section. Here's a snippet from my routes.rb: map.namespace :admin do |admin| admin.resources :contents end map.resources :contents Within my admin namespace, right now I am using the following: link_to content, admin_content_path(content) But I want to do: link_to content, content ...