ruby-on-rails

How do you do sortable tables plugin for rails?

This seems like a classic rails situation: I want to have a my index action display a sortable table of the items. I've looked at (and hacked at) some plugins, notably thoughbot's sortable_table and Michael Kovacs's sortable (the latter I have forked and improved). However, now I'm finding that sortable is somewhat incompatible with inhe...

How can I get form_for to autopopulate fields based upon a non-model hash?

I'm building a multi-step form in rails. It's not javascript driven, so each page has its own controller action like "step1" "step2" etc. I know how to do multi-step wizards through JQuery but I don't know how to keep rails validations per page without getting into javascript, hence this way. Anyways, my model is a User object but I'm...

tinyMCE turning <i> into <em> on getContent

in the dom in my tinyMCE editor i see <p> <i>testing 123</i> </p> but when i run tinyMCE.activeEditor.getContent() it returns <p> <em>testing 123</em> </p> Why is it changing <i> into <em>? Im having problems with this because i want to insert text dynamically that is surrounded with tags and things are getting confusing....

How do I detect whether or not code is being run from a rails server?

Hi all, I have a rails app and I run the main rails app on a mongrel server. However, I also have an comet server (using EventMachine) running using the rails environment (so it can access the database). However, Mongrel seems to mess up EventMachine. My question is, how can I detect whether or not I am running the rails environment fro...

PHP Includes in Ruby on Rails?

Ive been learning PHP and tried to get into RoR and the two are always compared.My question is, is there a PHP include equivalent for Ruby on Rails. To me the ability to include PHP files is it's most valuable feature. ...

executing code in rails after response sent to browser

Does Rails provide a way to execute code on the server after the view is rendered and after the response is sent to the browser? I have an action in my application that performs a lot of database transactions, which results in a slow response time for the user. What I'd like is to (1) perform some computations, (2) send the results of ...

Is it possible to create sub-applications in Ruby on Rails 3 or something like slices from Merb?

Does Rails 3 have anything akin to slices in Merb, or areas in Django where there is a layer of organization above the controller? I heard at some point that they may allow hosting one rails app within another but I can't find any information on that in the pre-release material. Any hints on how to do something like this? ...

Select all users that have a particular role (where users and roles are many-to-many)

My users have and belong to many roles, and likewise my roles have and belong to many users. How can I select all users who have the role "editor"? How can I select all users who have only the role "editor"? ...

Generating PDF's with signatures using Ruby or Ruby on Rails

I'm working on a Rails application that uses prawn to generate PDF's. Long story short, we want to be able to digitally sign generated PDF's. Im not sure where to start reading up exactly. Just wanted to ask if anybody else has been able to accomplish this before, and if so, what kind of resources I should be using to do it. Thanks! ...

How do I fix the fields_for error: @ "is not allowed as an instance variable n" in Rails?

My goal is to enable a user to be able to submit multiple NewsImages from a parent Blog form. My Blog model looks like this: # == Schema Information # Schema version: 20091006171847 # # Table name: blogs # # id :integer(4) not null, primary key # title :string(255) # body :text # profile_id :inte...

Customize authlogic error message

I recently switched from restful_authentication to authlogic for authenticating users for my application. I've been exploring the API, and I've found a helper for generalizing error messages and overriding the message with my own, but I was curious as to how you can remove these two lines: 1 error prohibited this user session from ...

Rails: model_url for custom action

Let's say I have the simple rails blog app. And I have a custom action, like page_views which shows the number of views of the post. class PostsController < ApplicationController def page_views #show some page views end end And there is also an associated view in the app/views/Posts folder. Now, in the routes.rb I have:...

rails :dependent => :destroy error - want to use alternate id for deletion

I've got a model named Song with has_many :genre_songs, :dependent => :destroy I've got a join model GenreSong (with genre_id and song_id) that I want to destroy when the Song records are deleted. It appears that rails is looking for a primary key to delete in the GenreSong model, since I get this error: Mysql::Error: Unknown colum...

User-defined routing

Hi everyone! I have three relevant models: Companies, Projects, and Links, and I am trying to create a system where we generate routes according to the Links they create, for example: www.site.com/the_company's_specific_path/one_of_company's_links One company has_many :projects, one project has_many :links. Summary of the structure:...

get the state in a url

i've read this article for ajax indexing how can i do to read the state in a url like this with rails? ex. http://mysite.com/controller/action#!pid=1237604&amp;id=1079297234 the state is: pid=1237604&id=1079297234 thanks ...

How do I use a nested attribute with a form_for 's select method?

We have a user model which :has_one detail. In a form_for a user, I want a drop-down to select the user's details' time_zone. I've tried <% form_for @user do |f| %> ... user stuff ... <%= f.select :"detail.time_zone", ...other args... %> <% end %> but I get a NoMethodError for detail.time_zone. What's the correct syntax fo...

Facebooker + Devise = "like_it" button : "b is undefined"

I'm using devise with the facebooker plugin. What is the best option to make a "like_it" button on my webpage without the iframe approach ? I have <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt; <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/Featu...

Why "has_many :line_items, :dependent => destroy" in the cart.rb model file causing failed tests

Why has_many :line_items, :dependent => destroy in the cart.rb model file causing failed tests I have been working through the "Agile Web Development with Rails" book and am about half way through the depot application (I did skip around a bit). When I go to run the default test ("the truth") I get failed tests. Trace says "/Use...

factory girl: association problem testing model which has validates_presence_of accepts_nested_attributes_for

hey, i have a simple associations: class Account < ActiveRecord::Base has_many :users accepts_nested_attributes_for :users validates_presence_of :users end and class User < ActiveRecord::Base belongs_to :account end i just want to run a simple test: describe 'a new', Account do it 'should be valid' do Factory.buil...

Setting up Unix for development dual boot with Vista and Windows Server 2008

Hi, I'm a PC guy and a Microsoft Platform Developer. I've got a new assignment from my client whiche has to be develop with open source technologies. Hhas already send me server information where I've to deploy. The hosting information he has given is CentOS environment with Ruby (with Rails) and Python support. I've chosen Ruby becaus...