ruby-on-rails

Git checkout <SHA> and Heroku

I created a local Git repo on my laptop and then pushed the source to Heroku creating a remote branch. After a few days of commits and pushes, I need to rollback to an earlier commit. Here's what I did. cd <app root> git checkout 35fbd894eef3e114c814cc3c7ac7bb50b28f6b73 Someone told me that doing the checkout created a new working tr...

rails code within javascript

I am trying to use some rails code withing a javascript and need to have that rails code be dynamically changed. Here's the line of code: $(this).replaceWith("<%= escape_javascript(render(:partial => 'shared/products')) %>"); The 'shared/products' is the part I want to change based off information passed earlier in the javascript. H...

Ajax request gets to server but page doesn't update - Rails, jQuery

So I have a scenario where my jQuery ajax request is hitting the server, but the page won't update. I'm stumped... Here's the ajax request: $.ajax({ type: 'GET', url: '/jsrender', data: "id=" + $.fragment().nav.replace("_link", "") }); Watching the rails logs, I get the following: Processing ProductsController#jsrender ...

Need some help for the issues that caused because of secret key in rails application

I have a weird problem. I have a rails application. When I am trying to run the ruby script/about command, it is displaying the details when the secret key in config/initializers/session_store.rb was removed or commented. When I place the secret key in the file and if i runs the ruby script/about command it is throwing error as c:/rub...

Rails transaction: save data in multiple models.

my models class Auction belongs_to :item belongs_to :user, :foreign_key => :current_winner_id has_many :auction_bids end class User has_many :auction_bids end class AuctionBid belongs_to :auction belongs_to :user end current usage An auction is displayed on the page, the user enters an amount and clicks bid. Controll...

How to rename model

I made a mistake early in development, and named one of my models with plural noun (Users instead of User). Is there an easy way to rename it and corresponding controller (similar to generating it with script/generate way)? ...

Can't access log files in production.

I was trying to run my application and check for some output on the production.log. However Ruby on Rails throws this error. Apache log Rails Error: Unable to access log file. Please ensure that /var/www/somefolder/someapp/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDER...

Parsing atom/rss feed containing multiple <link> tags with Haml on RoR

So, firstly, here's an Atom feed snippet which I am trying to parse: // http://somelink.com/atom <feed xmlns="http://www.w3.org/2005/Atom"&gt; <entry> <title>Title Here</title> <link href="http://somelink.com/link1&amp;amp;amp;ref=rss" rel="alternate" /> <link href="http://somelink.com/link2&amp;amp;amp;re...

What is the form_for syntax for nested resources?

I am trying to create a form for a nested resource. Here is my route: map.resources :websites do |website| website.resources :domains end Here are my attempts and the errors: <% form_for(@domain, :url => website_domains_path(@website)) do | form | %> <%= form.text_field :name %> # ArgumentError: wrong number of arguments (1 for 0)...

rails + rspec : Staying DRY when testing validations

Ok say I have the following model: class Country < ActiveRecord::Base validates_presence_of :name validates_presence_of :code end I'm doing the rspec unit tests for those validations. They look like this: it "should be invalid without a name" do country = Country.new(@valid_attributes.except(:name)) country.should_not b...

Rails validates_format_of

Hi, I want to use validates_format_of to validate a comma separated string with only letters (small and caps), and numbers. So. example1, example2, 22example44, ex24 not: ^&*, <> , asfasfsdafas<#%$# Basically I want to have users enter comma separated words(incl numbers) without special characters. I'll use it to validate tags from...

Where does `signup`, `login`, `register` methods come from

In this piece of code: ActionController::Routing::Routes.draw do |map| map.resources :line_items map.resources :orders map.resources :products map.resources :categories map.logout '/logout', :controller => 'sessions', :action => 'destroy' map.login '/login', :controller => 'sessions', :action => 'new' map.register '/regis...

Rails, Clearance, using User ID after logging in?

I'm using clearance (http://wiki.github.com/thoughtbot/clearance) for authentication in my rails app. But I'm trying to figure out how to grab the user's ID in a view after logging in. Any ideas? ...

Automating custom field creation in Redmine

I want to write a plugin for redmine that will depend on quite a few custom fields, so I would like to create the custom fields automatically. Ideally within the plugin code, or if not by a script I can run when I install the plugin - I really don't want to have to create 10+ fields through the web interface when I set this up, especiall...

What is a good third party transaction API platform to use for ROR?

I have been looking at paypal for a online transaction, but I wanted to know if there are other 3rd party vendor that offer a good service at a good price ( transaction fee) and ease of use of API for ruby on rails application. ...

Facebook Link attachment example in Ruby on Rails

How do you attach a link in ruby on rails similar to facebook link attachment where you get the title and the description of the link attached.? Could you help me with the code? Is there a good RoR tutorial? Could you help me with the link? Looking forward for your help. ...

Create calendardateselect from javascript

Not sure why I can't figure this out. When a user makes a selection, a javascript method is called, at which point I want to add a calendardateselect to an existing div tag from the javascript. According to the docs, it seems like this should work: var a = new CalendarDateSelect( document.getElementById("date_area"), {embedded:true, y...

Uploadify with ruby on rails 'bad content body' 500 Internal Server Error

I'm Getting this error in my development log while uploadify is uploading the file and in the view i get an 'IO ERROR' beside filename. /!\ FAILSAFE /!\ Thu Mar 18 11:54:53 -0500 2010 Status: 500 Internal Server Error bad content body /usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:351:in `parse_multipart' /usr/li...

Rails + AMCharts with vertical legend

I followed http://railsontherun.com/2007/10/04/sexy-charts-in-less-than-5-minutes/ to get regular line charts working on my rails app. Now I'm trying to use http://www.amcharts.com/stock/vertical-legend/ but the I seem to be running into issues. Can anyone tell by looking at the tutorial what needs to change to make it work? Thanks, Ell...

Downsides to using FakeWeb compared to writing mocks for testing

I never liked writing mocks and a while ago someone here recommended to use FakeWeb. I immediately fell completely in love with FakeWeb. However, I have to wonder if there is a downside to using FakeWeb. It seems like mocks are still much more common, so I wonder what I am missing that's wrong with using FakeWeb instead. Is there a certa...