ruby-on-rails

Geokit and Authlogic, geocoding the users ip address when they create a user

Has anyone done this? I'm confused at how I can make this work, first off I have my user model Geocoding with it works fine in IRB, just can't figure out how to get it to work in my project. Trying to use some examples from the readme here: http://github.com/andre/geokit-rails/tree/master. Anyhow here is what I have: class User < Act...

Rails: Responding to XML

I'm looking to respond to XML. In my show action, I have something like this: respond_to do |format| format.html { render :action => 'show' } format.xml { render :xml => @post.to_xml } end This will output all of the post's attributes. How would you go about outputting only some of the post's attributes. Also, say t...

rails run specific migration

I've deleted a table in the database, call it X. db:migrate no longer works. I have a migration file called CreateX. Is there a way to run just that specific migration? ...

check values before sending to controller in rails

In this code i have checkboxes for each item that give user ability to delete multiple items at once, but if the user press the remove button without checking any item it gives an error <% form_for :product , :url => { :action => :delete_selected } do %> <table border="1px"> <tr> <th> Select </th> ...

Using Inheritance with RoR

I'm working on my first Rails application (my first Ruby app, for that matter) and I have a best practice question about inheritance. I have to be able to upload physical media and I want to store the physical properties separately in the database so that certain attributes can be queried outside of the application as easily as within in...

Using shoulda macros with RSpec

I'm trying to use the shoulda macros within RSpec and am having some problems. I've done the following: spec_helper.rb: require 'shoulda/active_record/macros' Spec::Runner.configure do |config| ... config.include(Shoulda::ActiveRecord::Macros, :type => :model) spec/models/foo_spec.rb: describe Foo do it { should_have_i...

rails ajax update only once

I have a remote_form_for that I use to let a user know if their form was submitted successfully. In this method I have :success=>'updateMain() I would like to add an ajax update request to updateMain. The problem is that I can't find a way to make a single update request in rails (I know this is available in prototype). The closest th...

Rendering Partial onclick in Rails

I am trying to render a partial onclick to save on page loading time. <ul id="pop_twitter"> <% @topic_count.each do |k,v| %> <% @k = k %> <!-- make a link that onclick renders a partial below --> <li><% link_to_remote k, ?????? %></li> <ul id="twitter_<%= k %>" style="display:none;"> <!-- where the partial shou...

Testing with sanitize

I have this in my application_helper.rb: def bbcode(text) # Code snippets text.gsub!(/\[code=?["']?(.*?)["']?\](.*?)\[\/code\]/mis) { CodeRay.scan($2.strip, $1.to_sym).div(:line_numbers => :table)} text = sanitize(text, :tags => %w(span div table tr td br pre tt), :attributes => %w(id class style)) # Gist embedding text.gsub!(...

How to create a delete link for a related object in Ruby on Rails?

So let's say I have Posts and Comments and the url for show is /posts/1/comments/1. I want to create a link to delete that comment in the comments controller destroy method. How do I do that? ...

What are default respond_to formats for Ruby On Rails and how to go about adding new ones?

So here is what I have: def index @profiles = Profile.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @profiles } format.json { render :json => @profiles } end end I would like to add rss, atom and possibly some custom ones such as one that returns the image for ...

Ruby on Rails: Filter a list with AZ tabs (image explication)

Hi community... how can filter with AZ tabs in my list items? Thank you for your help... ...

rails: specify the HTTP verb in a redirect_to

Hi Here's a basic overview of my domain: a user has a list of courses the user can "select" a course. The corresponding action is invoked with the PUT verb, stores the course_id in a session variable and redirects to the "show" action of the selected course. when the user has only 1 course available, I want to redirect him directly to...

ajaxful-rating: multiple ratings on the same page

Hello, i'm using Ajaxful-rating (ajaxful-rating on github) and come across an issue. i display a list of items and want to rate/display the rate of each item. The problem is that the link_to_remote all point to the same item_id. I've looked at the source, but (being new to Ruby / RoR), i find it hard to identify the source of the proble...

Deploying rails application to root with passenger error

Hi guys, I am trying to deploy my rails application to virtual host's root with passenger but I had some problems. Error log: [Sun Aug 23 10:09:06 2009] [error] [client 91.187.5.190] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. ...

How would I invoke a rake script inside my rails application?

I want to execute a rake script from within a model. Beside calling it via backtick, is there anyway to include the rake library and call Rake::Task['some_task'].invoke. ...

How can I resize and watermark images in Ruby/Rails?

I am looking for gems that will allow me to resize and watermark uploaded images. I see a lot of posts on ImageScience and Mini-Magick but nothing that recent. I am looking for any experiences that will help me make a decision. ...

rails routing problem

I have some RESTful controllers and have added a custom method to application_controller. I have not changed anything in the routes to indicate this new method. The method is poll_memos. I have entered the following URL: /groups/1234/poll_memos I get the following error: Unknown action No action responded to 1234. Actions:...

Rails: how to load 2 models via join?

Hello, I am new to rails and would appreciate some help optimizing my database usage. Is there a way to load two models associated with each other with one DB query? I have two models Person and Image: class Person < ActiveRecord::Base has_many :images end class Image < ActiveRecord::Base belongs_to :person end I would like to ...

Has anyone used Railskits SaaS kit on Heroku?

I am considering purchasing the Railskits SaaS kit and deploy the app on Heroku. Has anyone deployed a Railskits SaaS based app on Heroku? What was your experience with it? Thank you. ...