ruby-on-rails

Controller helper_method

I was wondering why someone should use helper_method inside a controller to create a helper method, instead of creating the "normal" way, which is inside the helper file. What the pros and cons of that? ...

Can I have a nested form inside a remote form with Rails 3?

Hello, I am trying to build a remote form_for form for my customer model that has a nested field for my phone number model. I do not know ahead of time how many phone numbers will be submitted for each customer. No matter what I do, I can't get this form to submit correctly or pass the right params. Here's what I have right now (view i...

How do I perform complex, server-side form validation with JQuery/Ajax (and Rails)?

I'm building a Q&A app on Rails with a lot of complex validations (e.g. a user can't vote on his/her own questions, or vote on the same question twice, etc). I've been using Ajax+JQuery to update things on the page if the request goes through, but want to flash helpful error messages if there are problems. While I have no problem with cl...

Cassandra, mongodb or couchdb for Ruby on Rails

I think these three are the most popular non-relational db:s out there at this moment. I want to give them a try, but I wonder which one of these are most suitable for Rails when it comes to Gem, documentation and tutorial support. Eg. if I install a very good gem that is for Rails but this just use AR and mongodb, then it would be a p...

How to make an assets folder private in rails?

I'm using Paperclip for letting users upload photos to my app. Then, I'm saving the photos in /public/photos. Now, I want the photos being accessible just for some users. How can I set this permission system up? ...

Finding out deployment machine you are on in code (Rails)

Hi folks! My rails app is deployed to several machines. I need each machine to run different cron jobs (it will be a disaster if they all run the job). How do i tell my script which machine it is currently on? I am using the whenever gem, and i am thinking of adding the condition in the schedule.rb Example: My deploy/production.rb r...

MongoMapper Problems using Ruby Language

I installed mongo mapper gem and have the version 0.8.2. I opened the environment.rb file and editing it to use MongoMapper as shown below: # Be sure to restart your server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION #...

Should I learn Rails, Joomla or DHTML as a beginner?

This is not a core programming problem as most posts on this website are, forgive me for that but I didn't know where else to ask this. I am a beginner in web languages and want to build a small website for our family business, mostly a bunch of galleries that would display our different product lines with prices and some basic specs fo...

How to integrate a CMS into an existing Rails site

One of the challenges I see over and over again is a company with an existing website wants to integrate a Content Management System. Are there standard approaches/techniques for doing this that keep the existing website but allow certain pages or content snippets to be driven by the CMS? For example let's say you have a Rails website t...

Can I run multiple RSpec/Selenium tests in order without resetting browser state?

So I just started using Steak, which in turn uses Capybara, which in turn uses Selenium. So I've heard it's good RSpec practice to split testing into lots of little it-clauses, each testing a small piece of functionality. But then it makes a test run take a lot longer, because the same steps get repeated for each test. Say I'm testing...

Ruby on Rails Paths checking

Hello, sorry for my english, I have worked in a helper to create an objects tree based in :has_many associations and it's working fine, but I have a problem with links: some objects don't have an edit action to create a link (edit_object_path object_id). How can I to know, if an object has edit action? Regards. ...

I am not able to subtract two dates from each other using Ruby...why?

this is the code I have. It is a method for a contact.rb (Contact is a model): def event_delay event # find instance of contact_event puts "+++++++++++++++inside event_delay method" event_class = event.class.name event_id = event_class.foreign_key.to_sym #puts event_id contact_event_class = "Contact#{event_cl...

Problem with regexp trailing space

Hello guys I'm currently modifying Liquid Framework (http://github.com/tobi/liquid) in order to make it support literals. It's all nice and cool but I'm having a slight problem with the regexp I'm using. The following works great, except the fact that it captures the trailing space in $1 "{{{gnomeslab }}}" =~ /^(?:{{{\s?)(.*)(?:}}})$/...

Why won't hotmail let me include a name in addition to my email address?

I'm trying to send emails from my Ruby on Rails application, and whenever I use the following format: Jon Doe <[email protected]>, Hotmail marks the email as spam. However, when I use [email protected] without the name, it goes through fine. Anybody know how to get around this so my emails don't get sent to spam for hotmail users? I h...

How to monitor progress from ffmpeg?

I have this ffmpeg video encoder using Rails and I needed to report ffmpeg progress to the user. How can that be done provided that I am using Linux? ...

Text_field_tag default value if params are empty?

Hi I want my text_field_tag to have the current date as a default value if the params for params[:date] is empty, here is my code at the moment: <%= text_field_tag :end, params[:end] %> i want somthing like: <%= text_field_tag :end, if params[:end] then use this value else show current date %> thank you ...

Using Ruby on Rail's Authlogic gem, how do I display the login form on all pages?

I followed the tutorial exactly: http://github.com/binarylogic/authlogic_example But I am wondering how can I get the login form to appear on all pages when someone isn't logged in? I searched Google and looked at many forums for answers, but the only solutions I could find require me to define @user_session = UserSession.new for every...

ruby on rails get url string parameters

I have this url in my database, in the "location" field: http://www.youtube.com/watch?v=xxxxxxxxxxxxxxxxxxx I can get it with @object.location, but how can I get the value of v? I mean, get "xxxxxxxxxxxx" from the url string? Thanks and Regards. ...

Use of the TAGS element with Open Flash Charting 2 (by pullmonkey for rails)

Hi, I am trying to achieve this :: http://ofc2dz.com/OFC2/examples/Tags.html#SampleChart with ruby on rails - but its super tough! any advice out there? thanks! ak. ...

Rails ORM for CouchDB?

MongoDB has two popular ORMs for Rails: MongoID and MongoMapper. Are there CouchDB ORM:s for Rails 3? ...