ruby-on-rails

Accepting PDF documents and executable scripts

If I allow users to upload PDF documents (and only PDFs) is there any way a malicious user could include some executable script within or attached to the doc? What about standard word documents? What are some best practices if this is a requirement? (sorry that's totally 3 questions I know - but they all apply! ;)) I am using thoughtbot...

What's the best way to refactor this Rails controller?

I'd like some advice on how to best refactor this controller. The controller builds a page of zones and modules. Page has_many zones, zone has_many modules. So zones are just a cluster of modules wrapped in a container. The problem I'm having is that some modules may have some specific queries that I don't want executed on every pag...

Cleaning up my controllers, can I have Merb style action defs today?

In Rail 2.3.2 can I have merb style action definitions: Eg: instead of def show @user = User.find(params[:id]) end Can I have: def show(id) @user = User.find(id) end What kind of crazy monkey patching do I need to do to get this working, note I only need this working for MRI so ParseTree is an option. Note: there is a Rai...

How does rails use memory?

I have been using the Rails console a fair bit lately and its making me curious. Commands like >> app.get("/") => 200 >> app.html_document.to_s make me curious about how does Rails works in memory. Can anyone explain what's going in there? What objects are getting instantiated when and when do they get destroyed? ...

Which of these would be the best Rails server setup?

Here are my choices: Apache2 and Passenger Nginx and Mongrel Cluster Nginx and Passenger It's a linux vps with 256 ram. So, which do you guys recommend? ...

How to grab a record ID from a search form in rails

Hey guys, I'm very verrry new to rails. I'm using the autocomplete (plugin) text field to browse through titles of my records. When the user selects the record, I'd like to forward them to a custom built URL, based on that record's ID. How should I do this? Thanks! -Elliot To be more specific. I'm trying to make a simple search f...

What is the fully qualified name of a model in Ruby on Rails?

If I have 2 different classes with name User, say one in FooModule and other as a model in app/models/user.rb, how do I make sure I am using the correct one? EDIT: FooModule::User would definitely give me the correct one. What I had meant to ask was: If ApplicationController includes FooModule, would User or ::User still give me app/m...

S3 Image upload problem

Hi, I am uploading images to S3 storage by using paperclip plugin. its uploaded successfully. In my application user can change his profile photo. if user do the profile photo change its getting uploaded successfully , the problem is the browser will show previous photo only after the upload. after do the CTL + F5 then only the ...

Validate max amount af associated objects

I have an Account model and a User model: class Account < ActiveRecord::Base has_many :users end class User < ActiveRecord::Base belongs_to :account end Users belong to an account and an account have a user maximum (different for each account). But how do I validate that this maximum have not been reached when adding new users to ...

ruby Rmagick text width

Im using Rmagick in a ruby project to generate a title, All is working fine as below but i need to put an image after the title and i was wondering if there is any way to find out the width of the text i have just drawn? Thanks canvas = Magick::Image.new(600, 18){ self.background_color = '#212121' } gc = Magick::Draw.new g...

where do I get Serial Port Interface API for rails

Can any one tell me where do I get Serial Port Interface API for rails programming ...

How do I add 'required' to form label if specific option is set?

Using Rails, I would like to add: <span class='req'>&bull;</span> within my <label> tags in my views, if I set an option on the label form helper; i.e. <%= f.label :address_1, "Address 2:", :req => true -%> should produce: <label for="model_address_1"><span class='req'>&bull;</span> Address 1:</label> rather than: <label for="model_...

How can i save errors in a container inside a model and display it in the controller

Hi guys , i am currently trying to display my errors that i added to user object inside the controller simultaneously with my validation inside the model. like if maybe i have an error in my controller it display it immediately then return and without displaying the errors inside the model, i know that it has to return if my errors are ...

Session variables with Cucumber Stories

I am working on some Cucumber stories for a 'sign up' application which has a number of steps. Rather then writing a Huuuuuuuge story to cover all the steps at once, which would be bad, I'd rather work through each action in the controller like a regular user. My problem here is that I am storing the account ID which is created in the f...

What is the best framework for web-development to start with?

I want to get into web-development and trying to pick a framework to playground with as well as a develop complex web-app. I am considering the following: C# with ASP.NET MVC. Ruby on rails Tomcat/servlets/jsp For now, I am planning to run it on windows, yet might migrate it to Linux. I want to his framework to be fairly intuitive t...

Getting Started with CacheMoney

I recently installed cache-money. After some difficulties getting memcached and cache-money set up, I thought I had it working. It cached the one query on my login page fine. I login, and go to my message index page and get this error: indices delegated to @cache_config.indices, but @cache_config is nil: Slug(id: integer, name: strin...

Development productivity of Ruby on Rails vs. Java in 2009

Hi, I know this has been a hot topic in the past, spawning many flame wars and a tribe-like attitude in the forums. Some years have passed and Java has evolved: we now have more annotations for almost everything, nice scaffolding tools like Appfuse or Spring Roo, etc. I'd like to know, from people who have developed real projects on R...

Problem encoding UTF8 data from Rails app to Mysql

I'm having trouble saving UTF8 data in a form and having it correctly saved in mysql. In particular, via my ruby application I'm post a form that includes the following: Gerhard Tröster Which in my terminal I see is being updated in the database as: UPDATE `xxxx` SET `updated_at` = '2009-08-13 14:22:33', `description` = '<p><s...

Outputting script execution time on Ruby on Rails?

Hi, is there a way to output the execution time on the screen? For example, in my Rails application if I call a controller from the index controller, I'd like to have the time it took to query the data displayed on the bottom of the page. Thanks! ...

500 Responsecode while using warbler

I've tried to deploy a simple RubyOnRails app to tomcat app-server with the warbler gem. I simply generated a new app, with a simple scaffold and configured it to use the jdbcmysql adapter. Then i simply created and migrated the database, executed warbler and deployed the war to my local tomcat (Version 6.0.23). I can deploy the war and ...