ruby-on-rails

Add a view to an existing Rails app - simple?

I have a simple conceptual question that has stumped me. I am trying to simply add a new view called 'Owner Show' to a Recipients controller that I have. This will be a new page that shows an owner of a recipient, the "for-owners-eyes-only" details about that recip. I've created the hello world erb and named it ownershow.html.erb. I've a...

Please help rails problem with stringify_keys error

I have been trying to solve this for ages and can't figure it out. I have a form like so (taking out a lot of other fields) <% form_for @machine_enquiry, machine_enquiry_path(@machine_enquiry) do|me_form| %> <% me_form.fields_for :messages_attributes do |f| %> <%= f.text_field :title -%> <% end %> <%= me_form.submit '...

MySQL driver for Rails in Windows 7 x64

I've got problem with connecting to MySQL database on my freshly installed Windows 7 machine. I'm getting this error when I try to migrate my database. !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! 193: %1 is not valid Win32 application - C:...

Escaping Apostrophes Input by Users Through Text Fields in a Rails App?

Update: If you look at the javascript code that I pasted in the update below, I have single quotes around the variety.name variable. I think I was just following a tutorial in doing that. Turns out that when I switch those to double quotes, everything works fine. Question: Is this a stable solution? Or would it still be better to imp...

Ruby on Rails SQLite problem on Windows 7 x64

When I try to do db:create on sqlite database with this db config using Windows 7 x64 development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000 I get this, kinda funny error unknown error C:/Ruby/lib/ruby/1.8/dl/import.rb:29:in `initialize' C:/Ruby/lib/ruby/1.8/dl/import.rb:29:in `dlopen' C:/Ruby/lib/ruby/1.8...

config.gem requires gem?

I have a bunch of config.gem statements in my environment.rb file: config.gem "fastercsv", :version => "~>1.5.0" config.gem "parseexcel", :version => "~>0.5.2" config.gem "geokit", :version => "~>1.4.1" config.gem "facebooker", :version => "~>1.0.50" ... If I do "rake gems:install" then I get this issue: rake aborted! no such f...

Import CSV from url address and export as XML -- Rails

Two questions: How can I import a file from a web address, without a form? Example: Organisation.import(:from => 'http://wufoo.com/report.csv') How can I use xml builder without pulling from the db? More Info My company uses wufoo for web forms. The data from wufoo is exported as csv files. To get the data into my company's cms, it...

Raw POST from Ruby on Rails

I'm trying to do a raw POST to an internal page from a unit test, and for some reason I'm getting the following error: NoMethodError: undefined method `symbolize_keys' for #<String:0x258a910> unit/call_route_attempt_test.rb:10:in `test_response_from_call_info' My code looks like this: post :call_info, '<?xml version="1.0" encodi...

Pull objects from an association into an array in Rails

A user has_many :donations, a project has_many :donations, and a donation belongs_to :user and belongs_to :project. I'm looking for a sensible way to extract the projects associated with a user (through donations) into an array. I'm currently doing: def index @user = User.find params[:user_id] @projects = [] @user.donations.each...

Rails image_tag is looking at my production server for assets!

I read that by setting ActionController::Base.asset_host, you can control where rails looks for assets. However, by default Rails should look in '/public/...' Somehow my Rails app knows to look at my production address when in development mode and I have not set ActionController::Base.asset_host anywhere. I am not sure where it is fin...

Is it the best practice to store content in the database as html when content is written in markdown?

Or is just saving markdown and rendering it on requests usually okay? I'm writing a site that uses markdown for content. Stack overflow similarly uses markdown for comments and questions. I'm storing the content as markdown in the database and then rendering it to html when the user visits the site. I've got a feeling I ought to be st...

Most efficient way to get a subset of tagged objects from acts_as_taggable find_tagged_with?

For example, I have a named scope sfw_only in my Image model that returns images with nsfw == false. I'm also using acts_as_taggable_on_steroids - and I'm trying to think of the most efficient way to do something like the following. if !params[:tag].nil? if nsfw_mode @images = Image.find_tagged_with(params[:tag]) else @imag...

Rails: Modify Validation error reporting?

The standard Rails validation wraps my error-filled fields in a div of class fieldWithErrors. How can I change it so that the erroneous element's parent gets assigned that class instead of having a new div created on the page? EDIT: Per this website, this wraps errors in spans instead of divs, which helps my formatting a little, but I...

Iterative Parsing XML

Just getting started with Ruby and have a newbie question re parsing XML. I'm trying REXML (yes, I know hpricot and others exist, but I am starting with REXML to learn.) The problem is how to iteratively proceed through a XML doc like this: <?xml version="1.0" ?> <bars> <bar> <id>29</id> <foo>Something</foo> </bar> ...

Is it possible to get HTML tag autocompletion in Netbeans IDE?

I just installed Netbeans 6.7 for Ruby and one of the things that bugs me is I have to type both the opening and closing HTML tags even though it seems to recognize that I have completed the opening tag. Is it possible to configure it to automatically type the closing HTML tag for you, as some other IDEs do? ...

Count number of nodes in a level in a nested set

I am using Ruby (Ruby on Rails) and have a nested set of about 2000 nodes. Each node can only have two children. What is the best way to determine how many nodes are in each level? Do I have to crawl the entire tree looking for sibling to do this? Thanks! ...

When should one apply Code Refactoring techinques in rails ?

What ever i am coding is it a Refactored code or not ? This question always makes me think twice while coding in Rails . When Should one apply Code Refactoring techniques in rails ? ,Are there any best practices for refactoring ? , Scenarios which you have come across your development experience will help people coding Professionally an...

Ruby on Rails progress bar

I want to create file upload progress bar in my Rails application. I am Googling but couldn't find appropriate answer. Can anyone please suggest me how can implement the file upload progress bar on Rails .... Thanks in advance ...

Popup/New Window + Redirect_to + Rails

It is possible to redirect_to some url from the controller and open the url in the new window at the same time ? ...

Radiant mailer and flash message

Hello, I'm using Radiant with the mailer extension to provide a contact form on my website. I'd like to display a nice "your email has been successfully sent" message after sending the email. However Radiant seems to only allow redirect in it's configuration. Not to define flash messages. Would you know of a way to define flash message...