ruby-on-rails

Create default links to server-side logs

Is there a way to pre-populate a user's documents list with server-generated log files? A way to offer any files at a given path? Is this a job for plugins or native to some settings config? thx ...

Tips on deploying Ror

How can I go about deploying a Rails app on a cluster of Amazon EC2 servers? Any recommended guides? I maintain a RoR app (currently hosted on Heroku) that uses a DB and DelayedJobs). The app has a large footprint, and needs to be distributed on a cluster most likely. Any tips would be appreciated. Are there Amazon AMIs that replica...

Rails Asset Caching Breaks First few page loads

We're using Rails asset caching for JS and CSS like this: <%= stylesheet_link_tag 'reset','global','admins','autocomplete', 'date_input', 'tablesorter', 'partners', 'jqmodal', :media => 'screen', :cache => set_asset_cache(:admins) %> <%= javascript_include_tag :defaults, 'autocomplete', 'searchbox', 'jqmodal', :cache => set_asset_cache(...

Is Prince the best way to create PDFs in Ruby on Rails?

After several Google searches, it appears that the way to create PDFs in Rails from HTML and CSS (versus a new markup language) is to use Prince. With licensing at $3800 for my non-big-commercial app, I'm wondering if this is, in fact, consensus or people have an alternative they can share the whats and hows. ...

Inserting default "admin" user into database during Rails App startup

I'm building my first real rails application for a little in-house task. Most of the application tasks require authentication/authorization. The first time the app starts up (or starts with a wiped db), I'd like the process to be: User logs into the admin panel using "admin" & "admin" for authentication info. User navigates to admin ...

Ruby on Rails, autocomplete => "off" in text input fields, not working on Firefox

I have both a text_field and a text_area in Rails, and I want to disable the browser's auto-complete. Setting the attribute in either the text_field, text_area, or in the form itself, doesn't seem to make the browser stop trying to auto-complete. This is for Firefox 3.6.3 on OS X. Maybe it's more a browser issue than a RoR issue. Thanks...

Assistance using respond_to to find the right actions to render PDF in ruby on rails

Hi, I am trying out Prince with the Princely plugin, which is supposed to format templates that have the .pdf into a PDF generator. Here is my controller: class TodoController < ApplicationController def show_date @date = Date.today @campaigns = Campaign.all @contacts = Contact.all @contacts.each do |contact| ...

Starting socket server in ruby on rails on cloud environments (heroku)

Hi, I'm using heroku, and I can push a Ruby on Rails app just fine, I'm trying to convert this to a Socket server, basically I would need to bind to an open port, in this case, I know Heroku only does 80 22 and 443. Is it possible to bind to port 80 on those environments? Also, how would I setup the entry point for this socket server,...

Error message: uninitialized constant Rails::Initializer::MemCache

I've installed just about every library/gem that I could find for memcached/memcache, but everytime I attempt to run my application I get this error: Error message: uninitialized constant Rails::Initializer::MemCache Exception class: NameError I have tried $ telnet localhost 11211 and memcached is definitely running. Any ideas? (I'm...

Trying to convert existing production database table columns from enum to VARCHAR (Rails)

Hi everyone, I have a problem that needs me to convert my existing live production (I've duplicated the schema on my local development box, don't worry :)) table column types from enums to a string. Background: Basically, a previous developer left my codebase in absolute shit, migration versions are extremely out of date, and apparen...

What exactly is Arel in Rails 3.0?

I understand that it is a replacement for ActiveRecord and that it uses objects instead of queries. But... why is this better? will objects/queries be "easier" to create? will it lead to more efficient SQL queries? will it be compatible with all major DBs? - I assume it will. will it be easier/harder to use with stored procedures...

Association with Searchlogic

Hi I have a post model that :has_many :reply, when using searchlogic, doing Post.reply_content_like("search"), returns a result for every reply under that post, I only want it to return once. Anyone know a way to solve this ...

Can't run rails server as daemon

I'm using rails 2.3.2 and when I run script/server -d, the only output I get is => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 which is fine. But when I check for anything running on port 3000, i get nothing. Any ideas? ...

Unique view count.

I have a collection of links which are being displayed on the index page. Whenever a user clicks a link I want to keep a track of the number of unique views. I know it can be done by tracking the ips whenever a click happens by request.remote_ip and then the link of the page that was clicked. Is there any better approach ? Any plugins et...

How to add a new entry to a multiple has_many association?

I am not sure am I doing these correct. I have 3 models, Account, User, and Event. Account contains a group of Users. Each User have its own username and password for login, but they can access the same Account data under the same Account. Events is create by a User, which other Users in the same Account can also read or edit it. I c...

Rails - before_save that includes updated object

I have a before_save that calculates a percentage that needs to include the object that is being updated. Is there a one-liner in Rails that takes care of this? for example and this is totally made up: Object.find(:all, :include => :updated_object) Currently I'm sending the object that is getting updated to the definition that calcul...

Ruby on rails: Select options menu with default value attribute

I need to produce a select menu with a Default value on the list of <options> . Here is how I need it looks like. <select name="menu[parent_id]" id="menu_parent_id"> <option value="0">==None==</option> <option value="34">TEST</option> </select> Currently I use this select helper in my form <%= f.select(:parent_id, @parent_menus....

validates_uniqueness_of in nested model rails

I have a Project model which accepts nested attributes for Task. class Project < ActiveRecord::Base has_many :tasks accepts_nested_attributes_for :tasks, :allow_destroy => :true end class Task < ActiveRecord::Base validates_uniqueness_of :name end Uniqueness validation in Task model gives problem while updating...

Weird nil.include? error getting AR object's id (only happens after class is reloaded)

Hey all I have a line of code that's causing a "undefined method `include?' for nil:NilClass" exception, but i can't work out what's actually going wrong with it. After a bit of experimentation i discovered that it's caused by simply asking for the id of an AR object i have. ldb "question.id = #{question.id}" ldb is just a log...

Rails find all with association

I have what I think is a very simple problem (famous last words)... I have a Category model that has_and_belongs_to_many Events. I want to construct a simple and efficient query that finds all categories that have 1 or more events. (using Rails 3) I'm sure I'm having a dumb moment here - any help appreciated :) ...