ruby-on-rails

Single-user OpenID server with Rails

My website's root page automatically redirects all users to some subpage via http header. http://example.com/ → http://example.com/subpage I want to use my domain example.com as OpenID. The problem is that I have to add some tag to my root page, but it should redirect all users on subpage. I can change the type of redirection and use e...

HowTo: Create a ror project that has Email/Password authentication?

Is this possible out of the box with Rails? or is an add-on or hack required? thxs ...

rails: create Parent, if doesn't exist, whilte creating child record

Any best practices for the following?: I have Manufacturer model that has_many Inventory In my new Inventory form I want a field that maps to Manufacturer.name so that when one submits the new Inventory form the app: searches for a manufacturer with the 'name' from the form if it exists then assign the id to @inventory.manufacturer...

invalid multibyte escape after upgrade to rails 3 and ruby 1.9.2 -- dtext = '[^\\x80]'

I am upgrading my app from rails 2 to 3 and when i 'require' this file that has an email address validator i get an 'invalid multibyte escape' error with: dtext = '[^\\x80]' pattern = /\A#{dtext}\z/ Any thoughts? ...

How to use :conditions to compare (a datetime) with (datetime + 'number of days') ?

I'm building an application that checks when a user needs to change the oil of one of his cars. Here's how it works: The user enters the name of his car (e.g. 'Ford Mustang') The user enters the time the car will run on one oil change (e.g. 3.months) The user saves the car to the database Repeat above process for all his other cars. (Y...

Warden vs Rack::Auth::Basic. Doing HTTP-Basic-Auth in Ruby-Framework.

Hi... I want to create a WebService in Ruby (Sinatra, Padrino, maybe Ramaze... don't know yet...), but I definitely want to secure it... It will be the backeend for an Iphone-App, so I think SSL-Secured HTTP-Basic-Auth will be fine. I've been looking around at several authentication Frameworks and came across warden... Seems to be pret...

Ruby on Rails Devise user

I am new to ruby on rails. I am originally a PHP/mysql programmer. I can not seem to understand how you connect any posts to the user and display them (e.g. a post is successfully created with the user ID and then the users ID is queried to get his or her name.) I am using devise for authentication. def create poll = current_user.p...

How do you find out what controller/action you are in via ruby code?

I have a different subheader partial I want to render dependent on where I'm at in my application. How do I go about determining where I'm at via ruby? Or do I need to parse the URL? Example : If I'm at my root level I want to use /home/subheader, if I'm in controller 'test' I want to render /test/subheader, etc... etc... basically...

Image cache ruby on rails

Hi, Is there a Ruby on Rails way to do an image cache? Or should I just use javascript like this: test = new Image (50,50) test.src= "/images/test.png" Thanks ...

Setting up factory_girl with internal array in rails

Hi, I have the following shoulda set up which I would like to use factory_girl to have the fake model available in other specs. So far I have this: context "on POST to parse" do setup do @fuzzy_lead = LeadCapturer::FuzzyLead.new parts = LeadCapturer::LeadPartArray.new parts << LeadCapturer::LeadPart.new('Mc B...

Gems in plugins often not getting loaded, when running that plugin test

For example in open_id_authentication plugin. Inside folder test/test_helper.rb inside that plugin, it got: require 'test/unit' require 'rubygems' gem 'activesupport' require 'active_support' gem 'actionpack' require 'action_controller' gem 'mocha-0.9.8' require 'mocha' gem 'ruby-openid' require 'openid' RAILS_ROOT = File.dirname(_...

Ruby on Rails: Is it better to use outdated plugin, or use your own code?

When you are facing with this kind of dilemma, what do you usually do, and why? In my case, I want to create a user authorization system that works with facebook connect and openID. Authlogic is working, but unfortunately authlogic-openid is no longer supported (they really should clean up ancient codes on github!) Thanks! ...

jQuery and Rails 3

I'm introducing jQuery into a rails3 application, and have a question regarding best practices. I'm finding it very useful to do all my Javascript unobtrusively using jQuery, but I'm putting everything in application.js. The javascript is included in all my pages, as application.html.erb has <%= javascript_include_tag :all %> I'm also ...

How to clone Railscast episode 170: openid with authlogic

Here is the Github link: http://github.com/ryanb/railscasts-episodes/tree/master/episode-170/blog/app Running: git clone http://github.com/ryanb/railscasts-episodes.git Gave me an empty folder with .git folder. ...

What does "map.resource" in the route file do exactly?

Take the most simple example: map.resource:account 1) How different is it from defining all the names routes - like: :map.new_account "new_account", :controller=>"activity", :action=>"new" 2) How do you set an additional route within the resource definition? For example, say there is one more method for the resource :map.b...

Authorization plugins for RoR with Rails 3 support

Hi guys, Please name RoR authorization plugins with Rails 3 support, which you think is the best. Regards, Alexey Zakharov ...

frame, thread, and some other jargons in ruby-debug gem, what do they mean?

Hi, I am now trying to learn ruby-debug gem, but there are many jargons I am unable to catch up. Wondering if anyone could help with the explanations? I couldn't find them in http://bashdb.sourceforge.net/ruby-debug.html either. The author assumed we already understand them (where can I learn about them anyway?). For example here is a ...

Ruby on Rails: Default will_paginate to last page of results

Is there an easy way, to default will_paginate to last page? I would like to show user latest addition and allow to browse previuos pages of results... ...

Rails autotest with ubuntu and remote growl

I am using ubuntu to develop my rails apps in a virtual machine and I want to send growl notifications in my windows which is in a LAN (growl exists in windows also). I wrote a simple script to send notifications from ubuntu to windows remotely and it worked perfectly (with the ruby-growl gem), but I was wondering if autotest/growl sup...

Rails3 ajax upload with Iframe

Hi, before rails3 I had a working multiple ajax(mootools) file upload solution. I used form_to_remote with an iframe and responds_to_parent. In rails3 the ajax upload with form_tag remote => true, traget => "my_iframe" doesn't work. The the param[:uploaded_image]with the file is missing. I don't know why. Can anyone recommend a good a...