ruby-on-rails

Rails 3 - If I'm using RSpec, can I just delete the 'test' folder?

While trying to migrate, I keep getting this error: rake aborted! test-unit is not part of the bundle. Add it to Gemfile. If I'm using RSpec, can I just delete the test folder altogether? ...

Export HTML files from a SQLite 3 database (Ruby on Rails app)

Hi all, I'm new to Ruby on Rails, looking at using it for an app that I need to create. The story is: I'm using rails generate scaffold Page url:string parent:string content:text to create a Page scaffold. So we can then input a URL (hello-there.htm), a parent (my-folder) and lots of text, images, etc for the page into a web form, and ...

Capybara+Selenium not finding FB-Connect link/button

I have the following snippet in my html displaying a FB-Connect link: <fb:login-button id="mylogin" onlogin="try { window.location.href = "http://localhost:3000/"; } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('window.location.href = \"http://localhost:3000/\";'); throw e }"></fb:login-button> That works fine when manual...

Using non-English controllers in rails3

I have to following problem: If i want to follow the Rails naming convention i have to use the plural version of the model's name as my controller name. Example: rails g scaffold_controller Content In this case i have a model(Content) and the previous command is going to generate a controller with the name Contents. So what if I ha...

Telling jQuery which (unique) div to do an action on

My plan is to have lots of boxes (an undefined amount). When show box is clicked under a box, it shows that particular box. I have some unique divs in my html. The div is made unique by: <div id="box-<%=box.id%>"></div> In my application.js, I have $('.show-box > a').click(function(){ $('#box').show(); }); I obviously need to have...

Rails validating virtual attributes.

I this model: class Bunny < ActiveRecord::Base attr_accessor :number validates_presence_of :number validates_numericality_of :number end Whenever I submit a form to create this model I get the following error: undefined method `number_before_type_cast' for #<Bunny:0x103624338> ...

Rails has_many through fails on create method

Hi, Say I have 3 Models: User has_many :user_projects has_many :projects, :through => :user_projects Project has_many :user_projects, :dependent => :destroy has_many :users, :through => :user_projects, :uniq => true UserProject belongs_to :project belongs_to :user I then have a form that allows the creation of a new Project and c...

Rails 3 invalid multibyte char (US-ASCII)

I found a similar post here but I can't solve the problem anyway. I got this /home/fra/siti/Pensiero/db/seeds.rb:32: invalid multibyte char (US-ASCII) /home/fra/siti/Pensiero/db/seeds.rb:32: invalid multibyte char (US-ASCII) /home/fra/siti/Pensiero/db/seeds.rb:32: syntax error, unexpected $end, expecting ')' ... ed il valore della vita,...

Standard way of constructing Nested Urls in Rails?

Is there a built-in method in Rails to construct urls from an array of models, given these conditions? Nesting will be 2-3 models deep Each node in the tree will have an unknown class You could have single table inheritance (User, and Admin < User, etc.) How do I create urls from models like this: [@user, @comment].to_url #=> '/user...

gem server: How to update gems with missing rdoc?

I really like gem server command which bootstraps the webserver with local RubyGems Documentation Index. The only problem I have: some gems don't have rdoc files. How can I add missing rdoc(all gems are mainstream gems, not my own)? Installed via Bundler; Rails 2.3.5 ...

Declarative_Athorization: with_permissions_to for all models on single place

Hi All, Is there a way to have with_permissions_to in a single place globally so that it applies to EVERY finder method of all models. Actually, I have very big application and just added this plug-in for authorization. I don't want to use with_permissions_to with every find method for all models. Thanks, Imran ...

JRuby on Rails: Using custom Java classes in your Rails app

I just started with JRuby on Rails and absolutely love it. I know how to use current classes within the Java API in my Rails app, but if I wanted to create a new custom class written in purely Java code, how would I be able to use it in my Rails app? For example, let's say I created Dog.java: class Dog { private String name; publi...

Easy way to turn a Rails form into an AJAX form?

I have the following form in my Rails application: <% form_tag password_resets_path, :id => 'recoverPasswordForm' do %> <label for="passwordRecoveryEmailAddress">Email Address:</label>&nbsp; <%= text_field_tag "passwordRecoveryEmailAddress" %> <%= submit_tag 'Recover' %> <br /> <div id="forgotPasswordLoginLinkContainer"> ...

Using RoR and Active Record Session to implement a cheat-free game server

Hello. I'm diving into RoR and plan to build a few websites. Alongside the websites, I'd like to use RoR to build a simple RESTful game server API that can be used to orchestrate a two-player iOS game that I'm writing. The game is puzzle-based time challenge (the first player to solve the puzzle wins) and the players will only be comm...

Using Ajax in Ruby Forms, form_remote_tag

Hello, all, I am a little stuck on a exercise I am trying while learning RoR. I have a form I want to submit to my controller and have the results populate a div tag further down. I have rails 3.0 and ruby 1.8.7. When I try the following: Ajax List Demo Listing posts <%= javascript_include_tag 'prototype' %>...

RoR, Devise Gem. Welcome email on sign up.

Hey, how can I send welcoming email to user when one just signed up? I'm using Devise gem for authentication, SMTP is already set up; I just need to understand how to extend devise to send emails. NOTE - this is not confirmation email! UPD Solution: class User < ActiveRecord::Base after_create :send_welcome_email private d...

adding the id to the hash

Ok so i am creating an hash and i need to add the id to the hash..here is my code h = Hash.new {|h1, k1| h1[k1] = Hash.new{|h2, k2| h2[k2] = []}} @result, today = [ h, h.dup], Date.today Request.find_all_by_artist("Metallica", :select => "DISTINCT venue, showdate, LOWER(song) AS song, id").each do |req| # need to insert the req.id in ...

How to install .gem files in Ubuntu 9.04

Hi, I am new to rails . i am trying to install gems from the source . I AM HAVING ClothRed-0.4.1.gem file . How can i install this gem manually . This .gem file had data.tar.gz and metadata.gz file .. ...

Can Facebook's Javascript SDK work together with the older Facebook API?

Can the current Facebook Javascript SDK work with older Facebook API library? Right now there is code to load the current Facebook Javascript SDK by: window.fbAsyncInit = function() { FB.init({appId: '218565466928', status: true, cookie: true, xfbml: true}); }; // [...] initialize it And there is code to use the old ...

Rails naming conventions for models with forbidden names

Hi, I'm writing a rails application, and I need to name one of my model Test, and inside that model I need a class attribute - when I tried the first one, I couldn't run any UT since Test ceased to be a module - so I ranamed to Tst. I haven't even tried naming a column class - I went with clss. What names would you use? Are there any c...