ruby-on-rails

Access Rails 3 Session from Rack?

I was able to do the following in Rails 2.3.5 to access attributes that I set on the session from within my Rails app. Now in Rails 3, env["rack.session"] is nil. How do I do the same thing in Rails 3? class CallbackFilter def initialize(app) @app = app end def call(env) unless env["rack.session"][:oauth_callback_method...

Rails3 and Sass::Plugin::options

When I try to add "Sass::Plugin.options[:style] = :compact" to environment.rb I get "uninitialized constant Sass (NameError)" when I try to start up my server. I have added "gem 'haml', '3.0.0'" to my Gemfile. Anybody ran into this? ...

mysql error using Rails-- Please help

Alright I am sry for the noob question but this has been driving me up a wall-especially because I got it to work yesterday and I can't remember what I did.... I am just trying to use mysql with rails with a mongrel server. I set up the server fine and can run rails applications that don't need mysql but when I create a project usin...

weird behavior with acts_as_taggable_on

Edit The instructions on Github instruct you to use the gemcutter source for the gem. Currently, this installs version 2.0.5 which includes the bug I've detailed below. @Vlad Zloteanu demonstrates that 1.0.5 does not include the bug. I have also tried with 1.0.5 and confirm that the bug does not exist in this version. People struggling...

Large file download for a Rails project

One client project will be online two months later. One of the requirements changed is to support large files (10 to 15MB per RAW camera file, expected 1000 to 5000 files download per day) download worldwide for their customers. The process will be: there is upload screen via paperclip to the rails local public folder a hourly task to ...

What's the shortest way to generate a random IP address in Ruby?

Just like the title says, wanted for testing purposes. Thanks! ...

job portal design in ruby on rails

Hi, Anyone knows any open source job portal design in ruby on rails? Can you point me to that? ...

Getting proper indentation using XMLBuilder in a helper

I'm attempting to use a view helper to create some dynamic links based on if you're logged in or not. What I want returned, for sake of easy code readability, is: <ul class="right"> <li><a href="#">Login</a></li> <li><a href="#">Register</a></li> </ul> In the view helper I have this Ruby code: def loginh xm = Builder::XmlMarku...

DRY way of calling a method in every rails model

Along the same lines as this question, I want to call acts_as_reportable inside every model so I can do one-off manual reports in the console in my dev environment (with a dump of the production data). What's the best way to do this? Putting acts_as_reportable if ENV['RAILS_ENV'] == "development" in every model is getting tedious and i...

Use of time_ago_in_words in ActionMailer template

How do I access time_ago_in_words from the email template in my rails app? ...

Why callbacks for the after_find and after_initialize events is to define them as methods?

The only way to define callbacks for the after_find and after_initialize events is to define them as methods. If you try declaring them as handlers using the second technique, they’ll be silently ignored. Can anybody explain why is it so? Why specifically for these two callbacks? EDIT From the book:-- Rails has to use reflec- tion to...

render (and redirect_to) should somehow terminate the processing of an action?

def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) render :action => show end render :template => "fix_user_errors" end The previous code will generate an error (because render is called twice) in the case where update_attributes succeeds. The act of calling render (and redirect_to) sh...

can't dup NilClass when using Sanitize gem

Hi, Alright this probably is the worst error I have found ever. I have two projects, both using same code: Sanitize.clean(string, Sanitize::Config::BASIC) but one works and another fails. Problem is similar to this poor guy's post: http://stackoverflow.com/questions/2724342/cant-dup-nilclass-how-to-trace-to-offender Could anybody ...

How Does Rails 3's "data-method='delete'" Degrade Gracefully?

Rails 3 does some cool stuff to make Javascript unobtrusive, so they've done things like this: = link_to "Logout", user_session_path, :method => :delete ..converts to <a href="/logout" data-method="delete" rel="nofollow">Logout</a> But it just occurred to me.. When I turn off javascript the method isn't DELETE anymore, it's GET as ...

(Free) Text editor on Windows with a folder view?

I have to stay away from my MacBook and will use Windows for a while. I missed Textmate's folder view when editing my rails projects. Is there an editor on Windows with the folder view? I know there is the E text editor. But I'll save a few bucks if there is a free (cheaper) alternative, as I won't stay in Windows for long ... ...

multiple visual effects on one event

I have a code that looks like this. <%= link_to_remote "View results", { :update=>"uxUpdateDiv" , :url=>{:controller=>"exam", :action=>"results"} , :loading=>visual_effect(:appear, "uxcLoader", :duration=> 0.1), :before =>visual_effect(:fade, "uxUpdateDiv", :duration => 0.1), :complete => visual_effect(:appear, "uxU...

redirecting rails logger output to browser

anyone knows the easiest way to redirect the output of logger to the user browser? actually i want the rails logger to continously log to the file but i want to be able to catch all the logs as well so i can show them to the browser. thanks ...

Add Shortcut to Nested Route

I'm using nested routes and I want to provide some sort of a shortcut method. (I'm using RoR 3.0) The routes look like this. resources :countries do resources :regions do resources :wineries end end To access a winery route I want to be able to define a function that removes the need to specify a country and region each time....

Permission denied for folder creation using background_fu

Hi All, I am calling a controller method to convert a video file. This process is called using background_fu job. When the function tries to create a new folder in rails root it gives error i.e. Permission denied. The function performs well if not called in background job process. Can any one point out what can be the trouble. Thanks in...

Ruby: How to check if a string is a valid time?

I'm pulling data from a feed that I have no control over and I need to verify if a string I'm given is a valid time. Most of the time I'm correctly sent something like "2:35" or "15:41" but other times it's things like "AM" or "PM" (and no numbers)...so I ultimately just need to ignore those. So, how can I verify if the data is a valid...