ruby-on-rails

Generating a QR code in rails

Hi Guys. I want to generate QR codes in ruby on rails, to run in the background of my website written in rails. Saw this http://code.google.com/p/qrcode-rails/ but cannot work out how I could get this to work for me. Basically in RoR I want to: Pass a generator a string, my unique code, a 20 character length number (e.g. 320329288899988...

Is my output correct for creating a new object from the console?

I'm going through Ruby on Rails Up and Running by O'Reilly and have run into a question that I'm not sure where to go to for help. I'm at the part in the book where I'm creating new objects from the console and then saving them to the database. I've already created the database (MySQL), run the migration and finally verified that rails...

How do I make an RSS/Atom feed in Rails 3?

I'm pretty new to Rails 3, and I'm trying to make an RSS/Atom feed. I know about auto_discovery_link_tag, but what is the associated controller/action supposed to look like? Thanks! ...

How to change the column type from string to varchar using script/generate in a rails app?

Trying to migrate a sqlite3 db for a rails app to mysql db. The column named "content" was a string type in sqlite3. I want to change it to varchar (or perhaps text) in mysql. I am not sure if there is a way to do this by using "ruby script/generate" command. Any ideas? Obviously, I could start all over again with desired column types...

Why is rake db:migrate:reset not listed in rake -T?

Why are some rake tasks not listed by rake -T? Like db:migrate:reset? I can execute it without a problem, but why is it not listed there? Is there a way to get a real full list of rake tasks? % rake -T (in /home/zeus/projects/my_project) rake about # List versions of all Rails frameworks and the environment rake db:create ...

FB Iframe App: Use different stylesheets depending on whether the user views the app through my website or through Facebook

I'm developing a facebook app which can be viewed in an iframe on Facebook itself, or as a standalone site (the line between Facebook Connect and iframe apps seems to have blurred...). The stylesheet I have now looks good on my site, but doesn't look right when viewed through the FB iframe (probably b/c the browser screen is much bigger...

Why does Rails use helper methods like link_to instead of <a href...>?

I am learning Rails and I have noticed that Rails continously uses helper method such as link_to instead of just using plain html. Now I can understand why they would use they would use some helper methods, but I don't understand why they would prefer helper methods over just coding the html directly. Why does Rails prefer helper method ...

What’s wrong with my local Rails environment?

There is a Rails application I started a full year ago. It’s a Rails 2.3 app. Now, someone else has made remote changes (it’s on Github, sorry, but it’s private). And I have done sudo gem update that is, updated all my gems, including Rails (to 3). Realizing this, I have done rake:freeze:edge RELEASE=2.3.8 or whatever to make th...

OmniAuth & openid: getting certain fields from openid provider

I'm using the rails gem: OmniAuth to login users. When using an OpenId provider I would like to get certain field, like email and nickname but I don't see any documentation on this. Any ideas? thanks ...

Keep getting "coerce must return [x, y]" error with rturk gem

I swear this was working a few weeks ago but I keep getting "coerce must return [x, y]" when I use the rturk gem to create a hit. RTurk.setup(configatron.amazon.access_key_id, configatron.amazon.secret_access_key, :sandbox => true) hit = RTurk::Hit.create(:title => "SOMETESTTHING" ) do |hit| hit.assignments = 5 hit.description = "FOO...

How to route sign_up in Rails 3 using Devise

I am using Devise for authenticating a Rails application. I am now able to successfully route /users/sign_in and /users/sign_out to /sign_in and /sign_out via this code in routes.rb: devise_for :user, :as => '' How do I map /registration/sign_up to /sign_up? So that sign_in, sign_out, and sign_up all have the same pattern. Note that...

git push heroku master doesn't seem to work

I am following the guide on railstutorial.org. I get this error when I type the command on the title. Counting objects: 66, done. Delta compression using up to 2 threads. Compressing objects: 100% (52/52), done. Writing objects: 100% (66/66), 86.47 KiB, done. Total 66 (delta 3), reused 0 (delta 0) -----> Heroku receiving push -----> Ra...

Confusion over the tables for has_one and has_many

In the Rails ActiveRecord Associations guide, I'm confused over why the tables for has_one and has_many are identical: Example tables for has_many: customers(id,name) orders(id,customer_id,order_date) Example tables for has_one: these tables will, at the database level, also allow a supplier to have many accounts, but we just want on...

Rails 3 ActiveRecord Questions

I have a few queries for you Rails 3 gurus out there. How can you accomplish the following? The following pseudocode is currently invalid. Thanks all. @items = (@itemsA + @itemsB).order("name ASC") @item = Item.where("type = ?" and "condition = ?", "book", "new") @commenteditems = Item.find_all_by_type_and_condition("book", "new").in...

Rails 3 UJS dry Client + Server Side form validation

Form validation with jQuery is as easy as adding a classname to a field. Form validation with rails is as easy as putting a condition in to your controller (and/or model). I figure there should be a way to write the validations once and have them applied both client and server side. I've always been a fan of writing my own javascript,...

How to pass the params:id in the url explicitly ?

I have a User model and Posts model. I want to display the posts belonging to each user, via a URL say http://localhost:3000/my_posts/1" but Rails is reporting error saying that no matching route exits for http://localhost:3000/my_posts/1. Rails looks at the complete url : "http://localhost:3000/my_posts/1" as a route , but my i...

warning Insecure world writable dir

I get this everytime I run: rails server I get: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 I searched for a solution here and they said to type: chmod go-w /usr/local/bin But I get this error: chmod: Unable to change file mode on /usr/local/bin: Operation not permitted I am using OSX btw. ...

ActiveRecord has_many relation prevent orphaned newly created object

Suppose I have an Comment model that belongs_to a Post model. I want to make it so that creation of a new Comment instance (whether by new, create, find_or_create_by_x, etc.) will fail (preferably raise an exception) unless the Post is set immediately (either by passing it in as a parameter or by always referencing the post when creatin...

Problem with same resource, accessible via two routes.

I'm developing simple image sharing site to train my ruby-on-rails-fu. I have following resources in my config/routes.rb file. resources :users do resources :images end resources :images Here's the problem I'm facing - how should I go about implementing functionality like "latest images" and "your image subscriptions"? Having vanil...

<% %>(without equal) in ruby erb means?

i found this "executed with no substitution back into the output" , but maybe my English wasn't too good , i cant really understand what it means. Can anyone help out? ...