ruby-on-rails

Position of object in database

Hi! I have got model Team and I've got (i.e.) team = Team.first :offset => 20. Now I need to get number of position of my team in db table. I can do it in ruby: Team.all.index team #=> 20 But I am sure that I can write it on SQL and it will be less expensive for me with big tables. ...

Why does ruby-debug say 'Saved frames may be incomplete'

From time-to-time I get this when a breakpoint is triggered. It looks like stack frames aren't getting saved so I can't step back through the call stack - a real pain. See below for an example --> #0 BatchProcess.add_failure_record(row_id#Fixnum, test#Struct::Test, message#String,...) at line server/processes/batch.rb:309 Warnin...

is_admin? function in rails? - undefined method Error

Hello! At the moment, I am creating some kind of admin panel/backend for my site. I want to do the following: Only admins (a user has a user_role(integer) --> 1 = admin, 2 = moderator, 3 = user) can see and access a link for the admin panel. So I created an admin_controller. In my admin controller I created a new function called is_admin...

Ruby On Rails and UTF-8

I have an Rails application with SayController, hello action and view template say/hello.html.erb. When I add some cyrillic character like "ю", I get an error: ArgumentError in SayController#hello invalid byte sequence in UTF-8 Headers: {"Cache-Control"=>"no-cache", "X-Runtime"=>"11", "Content-Type"=>"text/html; charset=utf-8"} ...

Ruby On Rails : db:migrate do not run

Hi, When i run this command i have an error : rake db:migrate --trace rake aborted! NoMethodError: undefined method `ord' for 0:Fixnum: SET NAMES 'utf8' see the log file here : http://patxi.mayol.free.fr/public/trace.txt my database.yml file is here : MySQL. Versions 4.1 and 5.0 are recommended. # development: adapter: ...

Pass authentication between php and Ruby On Rails application

Hi, I have a simple Ruby on rails application that I want to integrate with an existing php website. I only want that users who's been authenticated by the php application would have access to my Ruby on Rails application (it should appear to the user as the same website, in the same domain, though it can be a different sub-domain if I ...

RESTful membership

I am currentlly trying to design a RESTful MembershipsController. The controller action update is used only for promoting, banning, approving,... members. To invoke the update action the URL must contain a Parameter called type with the appropriate value. I am not too sure if that is really RESTful design. Should I rather introduce sepe...

Mongrel with Ruby 1.9.

When starting the server, I get this strange error after updating to Ruby 1.9: " [BUG] cross-thread violation on rb_gc() ruby 1.8.6 (2008-08-11) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. " My mongrel version is 1.1.6,...

Grails vs. Rails

Any dynamics in the community that would let you chose Grails or Rails? ...

To maintain session accross xyz.com and www.xyz.com.

I have a rails website on www.xyz.com. After I log in to www.xyz.com, if if move to xyz.com, I need to log in again, ie the session is not maintained. How to make www.xyz.com and xyz.com use the same session. ...

How to enable page caching in a functional test in rails?

Is it possible to turn on page caching for a functional test? The following didn't work: class ArticlesControllerTest < ActionController::TestCase def setup ActionController::Base.public_class_method :page_cache_path ActionController::Base.perform_caching = true end end thanks in advance Deb ...

What languages, frameworks, and technologies have you used to implement document searching?

I am at a new company and one of our goals is to implement a document search portal for our team and our clients. I am a bit worried that if we use an external service provider like Salesforce or some other ECM in the cloud there will be a lot of integration work in the future. From a client perspective, these documents will also exist...

date in future for Rails

Hello, I am trying to make a validation that will validate that the entered date is in future and that the selected date is in the next 7 days. In order to validate if the date is in future I use; valid_until.future? and this one works fine, but to make a validation to check if the date selected is withing 7 days from now? ...

Ruby on Rails: Updating table record on a timed basis

I'm trying to create something similar to the stackoverflow "user score" on my site with a mysql. I don't want to be calculating this score every time a user is accessed because multiple user scores will be displayed at the same time and the way it's calculated doesn't require it to be updated frequently. My thoughts are to update all ...

Where to reopen a class in RoR

I'm attempting to reopen the String class in rails and add a bunch more methods for my app to use. Writing the code isn't a problem - my question is rather about where this code should go. It doesn't make sense to me to reopen a class inside a different model file, because it really has nothing to do with any of the models specifically....

Store data in Ruby on Rails without Database

I have a few data values that I need to store on my rails app and wanted to know if there are any alternatives to creating a database table just to do this simple task. Background: I'm writing some analytics and dashboard tools for my ruby on rails app and i'm hoping to speed up the dashboard by caching results that will never change. ...

What are useful Emacs features for Rails development

What Emacs feature(s), packages, add-ons, etc. helps you in your daily Ruby On Rails development? ...

Unknown user 'app' with capistrano

This is my first time trying to set up capistrano to deploy a rails application. I am deploying from my local machine to my remote server that has the repo, web, app, and mysql servers all on the same machine. I am following this walk through: http://www.capify.org/index.php/From_The_Beginning I get to the command cap deploy:start Th...

Is there any way to disable Erubis from printing "** Erubis 2.6.5" when starting the Rails environment?

I have several frequent Cron jobs that are run via Rake and the output of those jobs are e-mailed (via a MAILTO). Due to the fact that these tasks load the Rails environment (which includes Erubis) they always prints out "** Erubis 2.6.5" on startup. This means that an e-mail is always generated since Cron receives output. Is there an...

floating point precision in ruby on rails model validations

Hello I am trying to validate a dollar amount using a regex: ^[0-9]+\.[0-9]{2}$ This works fine, but whenever a user submits the form and the dollar amount ends in 0(zero), ruby(or rails?) chops the 0 off. So 500.00 turns into 500.0 thus failing the regex validation. Is there any way to make ruby/rails keep the format entered by the us...