ruby-on-rails

Ordering columns in Rails, cakephp style.

CakePHP's built in pagination helpers automatically allow column ordering in the view. If you bake the view you get a link on each column to order it by that data. Is there a way to get this functionality in Rails? The standard will paginate doesn't offer it, anyone know any good ones? ...

How to remove the action argument from Rails link_to function?

Hi, Not sure how to frame this so here goes.... I have the following link_to tag: <%= link_to("My test title",{:controller=>"search", :action=>"for-sale", :title => listing.title, :search_term => search_term, :id=> listing.id}) %> and the following custom route in my routes.rb file: map.connect ':controller/:action/:title/search_it...

How to trace Bouncing E-mails in Action mailer (Rails)

Hi, I am using Active mailer to sending Emails, I want to trace the mail ids which are bounced when i am sending the mails to the user. Please give your valuable comments guys. Thanks in Advance. *HIKKU ...

newbie: Rails on remote Apache server not displaying index.html.erb

I played around with Rails on my laptop (running Linux + Apache + MySQL) and had no trouble getting the Getting Started with Rails tutorial to work locally. Now I'm trying the same thing at work on a remote Mac OS X + Apache server, and things aren't quite so rosy. I typed rails blog -d mysql to create a directory called blog in /Libra...

uncorrect encoding(RoR)

I'm have a rails project. I'm make following: script/generate scaffold product title:string description:text image_url:string as in book(Agile Web development with Rails) and rake db:migrate. When I'm create a new product, post show as '??????'. In file database.yml section encoding is utf8, but in phpmyadmin encoding: latin1_swedish_ci....

Action Controller: Exception - ID not found

Hi Everyone, I am slowly getting the hang of Rails and thanks to a few people I now have a basic grasp of the database relations and associations etc. You can see my previous questions here: http://stackoverflow.com/questions/2714621/rails-database-relationships I have setup my applications models with all of the necessary has_one and...

Limit a user to view only associated records in rails

I have an application with three Models (Profile -> SubModel -> SubSubModel) chained together with has many relationships. I am trying to limit a user, after logging in, to only retrieving records that are associated with their Profile. I am very new to rails and this is what I had been trying in the Profile model has_many :submodels, :...

How do I create a controller and action without a model?

I have several models: Email Letter Call All three belong to a model Campaign. And a Campaign has_many Contacts I envision being able to see a schedule for Today by going to domain/schedule/today What I'd like it to do would be to show all the Events (Email, Letter, Call) that have to happen today for each campaign. I tried the f...

Does CSS have a "start over" feature?

I'm using calendar_date_select (henceforth CDS) in a Rails application, and have a stupid question. When I embed the CDS component in the middle of an already-CSS-styled page, all manner of things go ugly-wrong with it (spacing, fonts, etc.). Clearly the elements inside the CDS have inherited unwanted stuff from the styles already workin...

How should approach allowing users to create notes with revisions?

I'm working on a Rails project where I want to allow users to create individual notes, which are really just text fields at this time. With each note, the user can edit what they have previously written, but the old version is kept in a revision table. I'm trying to figure out the best way to approach this. My initial thoughts are to ...

Can you recommend an in-browser Ruby/Rails 3D renderer?

I want to draw some 3D network diagrams in a web browser, and the data for these diagrams are in a Rails app (in the database). I already use flotomatic as a Rails interface for pretty Javascript plots (e.g., independent variable, dependent variable). Certainly there are packages for drawing simple things in Javascript. What I'm lookin...

Local data about an ActiveResource

Using Ruby on Rails, is there any clean way to store data locally about a remote ActiveResource? For example, I'd like to add a local field like requested_at to store the last time the resource was requested from the remote API. ...

How do I reconnect to Memcache when forking in rails?

I have a rails 3 application, and a script called by rails runner. This script forks and does some stuff in other processes. I do the proper thing with ActiveRecord before forking, where I disconnect-fork-reconnect and all that jazz. My question is I also use memcache for the Rails.cache but should I be disconnecting-reconnecting that t...

I have an incorrent asset_host, but can't change it

In the console, development mode: ActionController::Base.asset_host => 192.168.2.55 which happens to be a previous DHCP address. I checked: RAILS_ROOT/config/environments/development.rb RAILS_ROOT/config/environment.rb ... and there is nothing set here. Even if I add config.action_controller.asset_host = "http://127.0.0.1" ...

Schema for storing "binary" values, such as Male/Female, in a database

Intro I am trying to decide how best to set up my database schema for a (Rails) model. I have a model related to money which indicates whether the value is an income (positive cash value) or an expense (negative cash value). I would like separate column(s) to indicate whether it is an income or an expense, rather than relying on whethe...

Rails create_table query

Hi, I am a beginner in Rails. In the following code,there is an id which is set as false. What's the meaning of it? class CreateCoursesStudents < ActiveRecord::Migration def self.up create_table :courses_students, **:id => false** do |t| t.integer :course_id,:null => false t.integer :student_id, :null => false ...

Any working tutorials for Authlogic?

I've been trying to build my first rails app and have gotten stuck on the issue of user authentication. I've found a number of tutorials for using various plug-ins to do this, but so far every single one of them is out-dated, and as a result, broken! From what I've read, I think Authlogic may be the best fit for me, and I've tried two ...

Rails request forgery protection settings

Hey, please help a newbie in Rails :) I have protect_from_forgery call (which is given by default) with no attributes in my ApplicationController class. Basically here's the code: class ApplicationController < ActionController::Base helper :all # include all helpers, all the time protect_from_forgery helper_method :current_user...

Dynamic Attachment Size for Paperclip (Rails)

Is there anyway to have the validates_attachment_size except a dynamic file size limit? Here's an example: class Document < ActiveRecord::Base belongs_to :folder has_attached_file :document validates_attachment_size :document, :less_than => get_current_file_size_limit private def get_current_file_size_limit 10.mega...

Get paperclip to crop the image without validating

Hello fellow stackoverflow members. I have been following this guide to enable users to have their own avatar. But i have bumped in to a litle problem. When the user is cropping the image the model tries to validate all my validations. My user model looks like this: class User < ActiveRecord::Base has_attached_file :avatar, :styles...