ruby-on-rails

Why does this not work: link_to(current_user) do

<%= link_to(current_user) do %> #show other stuff between anchors like this: #<a href="/user/bob">show other stuff between anchors</a> <% end %> The error I get is: compile error syntax error, unexpected ')' ...t(( link_to(current_user) do ).to_s); @output_buffer.concat ... Why an unexpected ')'? ...

How to configure my app to not list all available actions in my Users controller?

When I navigate to: http://localhost:3000/users/1 I get a page that says simply: Unknown action No action responded to show. Actions: create, current_user, logged_in?, login_required, new, and redirect_to_target_or_default Isn't this a security risk since it tells users of my app exactly which methods are available in my User...

serving a file from temp with rails on read only file system

I'm deploying my apps now to a server that has a read only file system. I was using a gem to make a zip file and randomly plopping it in /public somewhere. Now I can only write to tmp - how do I serve the user that file out of the tmp folder? ...

Paperclip gives Permission denied error with samba mount

In my development environment the codebase is mounted on a ubuntu-server VM using a samba mount, it is mounted as root and I run mongrel as root. When I try and upload a file with Paperclip the file saves fine but then it seems to have problems creating the different styles. I get the following error: Errno::EACCES (Permission denied ...

Any problems with multiple foreign key columns in a Rails class?

I'm coding a site that's using tags. Two other classes (Foo and Bar) both will use tags, but the tags used in Foo won't apply to Bar, and vice-versa. So I created the Tags table with both foo_id and bar_id columns, so when a record is saved, the foreign key for the correct object-type can be added. Will this cause problems? Is there ...

Nested objects and validates_presence_of

I have a nested object that is a type of User (say Sub). I had assumed when saving Sub the User validations would be run as well, but apparently not? How would I run all validations in User when creating Sub? ...

Get inf-ruby to use ruby version manager (rvm)

I have the ruby version manager installed and use the ruby implementation installed by RVM set to the default so that 'which ruby' shows '~/.rvm/ruby-1.8.6-p383/bin/ruby' yet when I open an inf-ruby buffer in emacs, it uses the ruby installed in /usr/bin. Is there a way to get emacs to respect the path for ruby the same way the she...

Custom getters in Ruby on Rails

I have a MailingList model that has_may :people For most of my application, I only want to get people that are active So @mailing_list.people should only return people that are active In my model, I can't do def people self.people.find_all{ |p| !p.activated_at.nil? } end because that keeps calling itself. What is the ruby/rails...

Too Many Rails Routes?

I'm working on a Rails application right now and the site currently has about 30 routes(map.connect). I expect that to eventually reach about 60 or 70. Is there any side effect of having lots of routes? I guess I'm just paranoid! :) Thanks ...

What does Twitter api return a 400 error in production

I have a Twitter app that works fantastic locally - it searches for keywords then for each user it grabs their info using Hpricot to parse the xml e.g. Hpricot(open("http://twitter.com/users/show/"+myuser+".xml")) Works fine locally but when I go love it fails. Looking at my log I get this error: OpenURI::HTTPError (400 Bad Request): ...

How to reformat the mp3 filename which is saved through paperclip

I upload/save mp3 files through Paperclip, it transforms the name with underscores when it saves it. For example if I upload "Gould Stokowski 1.mp3" it saves into the the db as "Gould_Stokowski_1.mp3". How can I take out the underscores (replace them with spaces" when I retrieve the file and I want to display the name. ...

act_as_revisable returns ObjectRevision instead of just Revision

I have a model Item: class Item < ActiveRecord::Base acts_as_revisable end When I try to use Item.find(2, :with_revisions) it comes back as an ItemRevision class instead of an Item class and I can't do things like assigning from another model (i.e. ItemList.items << item). Is there a way to make it return Item or a way to make it i...

overriding the RAILS default MIME type for the entire application (the site)

Does someone know an elegant way to set the MIME content_type default to a non-HTML (and non-XML) value for an entire RAILS site without altering the RAILS base classes? I am trying to flip a site to 'text/vnd.curl'. Over at http://eclectic-pencil.blogspot.com/2009/10/curlgen-with-ruby-rails.html I have collected some notes on what I...

Best way to handle different types of Users?

I have a large Rails app that has 34 different types of Users through Single Table Inheritance. When the app was initially designed, it was assumed that the User would have different behaviors based on type. This assumption was wrong, so I'm looking to refactor. The question is how would you refactor out the User STI? Add a ton of boo...

Associating multiple ids on creation of Item

G'day guys, I'm currently flitting through building a test "Auction" website to learn rails. I've set up my Auction and User models and have it so that only authenticated users can edit or delete auctions that are associated with them. What I'm having difficulty doing is associating bid items with the Auction. My models are as follows...

multi level user groups

I'm trying to determine the best structure to approach multi level user groups. Thus far I've created one object called "User" which i assumed could potentially be broken into different levels. Or should I simply create different tables for each user group? ...

Render partial for model with nested attributes in another model

I have a rails application that models a house. house contains rooms and rooms have nested attributes for light and small_appliance. I have a calculator controller, which is how end users will access the application. My problem is that I can't get the partial for adding rooms to render and submit correctly from calculator. The initial ...

Ruby on Rails: Sum table column row values based on other column data.

I have a table with columns 'id', 'resource_id', 'read_time', 'value' where 'value' is a float What I am trying to accomplish is to return a list of records such that the 'value' of each record is the sum of all the records at a specific 'read_time' but having differing 'resource_id' values. I am wondering if there is a clever way (ie ...

How to determine how much load a Rails application is under automagically?

We have a series of applications that we host on services such as Heroku which are able to scale up and down on demand. What we would like to acheive is a management tool that determines how much load a specific application is under so it can auto scale the app on a needs basis. What are the best ways of figuring out application load i...

Should I refactor with hobo?

Hello, I have a created a userdriven gallery with Ruby on Rails.The site is using a few plugins to create friendly links, permissions, pageless pagniation etc. The application controllers and views has gotton quite complex and I find it difficult and very time consuming to work with. So I thought about rebuilding the app with hobo, as i...