ruby-on-rails

Malicious requests from search.live.com hitting production server

I've been checking my production.log today and there's a number of requests hitting my site that appear to be malicious, but I'm confused as to how they're even getting to us. For example: Processing PublicController#unknown_request (for 217.23.4.13 at 2009-11-09 09:15:52) [GET] Parameters: {"anything"=>["results.aspx"], "action"=>"u...

RoR - make links clickable that show up in a user comment

I am looking for a Ruby script that takes a piece of text, and makes any links click-able that show up in it... Does anyone have something like this? For example, if I wrote a comment and said "Come check out my site at http://www.example.com", then the link would be click-able like an html tag. Thanks, Josh ...

Is there a "Code Complete" book for Ruby?

Hi there, I began reading the book "Code Complete" 2nd edition, but stopped reading when I noticed most of the solutions were easily solvable in Ruby with Ruby idioms. Is there a similar book for Ruby? Here's the version that I started reading: http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670 ...

Possible to use a base class with ActiveRecord::Migration?

If my models look like this: (app/models/letter.rb) class Letter < ActiveRecord::Base def cyrilic_equivilent # return somethign similar end end class A < Letter end class B < Letter end Can my migrations also follow this pattern: class CreateLetter < ActiveRecord::Migration def self.up create_table :letters do |t| ...

Is there a easy-used two-way encryption method for string in ruby?

Is there a easy-used two-way encryption method for string in ruby? ...

How do i create a form that inputs multiple items of a model?

I have a simple point of sale application written in ruby and rails, and hobo. Originally intended to be for only one product at the time, now the client wants to add multiple products into the sale model Besides that i am using brands for categorizing products and in my new sale form i use ajax in order to populate a select product me...

how do you compare a param to every item in an array in rails?

i have a codes model and i a basically have a form wich should authenticate simply to every code recorded so my controller is: def cancel_sale @codes = Code.find(:all) @codes.each do |c| @code = c.name end if params[:auth] && params[:auth] == @code something else @mensaje_de_salida = "wrong auth code" en...

What frontend editor for Rails?

Hello everybody! At the moment I am building my new Website. On my Website, users are allowed to post some code (Java, Rails, Ruby, HTML, CSS,...). Now I want to format that code in frontend like on Stackoverflow. Is there a plugin I can use in Rails? I had a look on some rich text editors, but most of them did not do what I wanted them ...

Odd time store behaviour in ActiveRecord

I have the following entry in my database: t.time :my_time_stamp In my controller I update it like this: model.update_attributes(:my_time_stamp => Time.now.utc) I can see that I'm writing: Mon 9 November, 8:54.54 UTC 2009 However, when I later read this value I get: Sat Jan 01 08:54:54 UTC 2000 It seems that the time part has...

ActionMailer long line is broken.

Hi, I am sending an email from a rails app with HTML format. It's utf8 format and I write Korean. Some characters are broken when I get it with gmail or yahoo mail. I checked the log and it sent ok. But when I checked original text from gmail, a long line was forced to break line. Correct text: 연합회 홈페이지는 Broken text: ...연합회 � �페이지...

Rails and ASP.NET MVC when to use each?

Hi, we have a mixed development environment using ASP.NET MVC and Ruby on Rails. We have come from a purely C# / ASP.NET background, but now have some rails experience and we love both. Problem is deciding at the beginning of a project which one to use can sometimes be tricky. Any tips for how to explain to the non technical members of...

How do I set a model instance as invalid after validations are run but before it's saved?

Hi. I have a standard active record model with an attributes that is required: class Sample < ActiveRecord::Base has_many :colors before_validation :grab_colors validates_presence_of :size validate :number_of_colors private def grab_colors # grab x number of colors | x = size end def number_of_colors self...

[Rails] Can a model "belongs_to" either/or more than one model?

Apologies if this is a slightly noob question, but looking to clarify my thoughts on this. I have a model that can EITHER belong to one model, or another. For example: Let's say I have a Team model and I have a Member model, and both of those models can have one BankAccount. class Team has_many :members has_one :bank_account end c...

overwrite javascript_tag to put all inline javascripts at the end of the page (for better performance)

For better frontend performance, it's best practice to put your scripts at the very end of your HTML code. I did that for a pretty big and complex page I'm working on right now and the problem I run into are many inline scripts in the views, mostly generated by Rails' built-in JavaScript helpers. These scripts depend on the libraries th...

TDD/BDD Rails Cucumber / RSpec duplication

Can someone please clarify using a SIMPLE user story the full slice of what Cucumber would be used for and what RSpec would be used for? I purchased the RSpec book the other day and have been going through it. The author seems to be quite vague at times. What I'm thinking of if the user story is something like (please excuse the synta...

How to get SQL queries for each user where env is production

Dear all, I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: module SqlHunter class ActiveRecord::ConnectionAdapters::AbstractAdapter @@queries = [] cattr_accessor :queri...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an light among netbeans and aptana? ...

Ordering a hash to xml: Rails

I'm building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml ...

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::Base belongs_to :role belongs_to :user end class Role < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :users, :thro...

Handling a view-backed model that doesn't really belong to the form it's displayed on

Kind of hard to explain but I'm going to try: I have a model called Message, which represents a request for an email to be sent out, a model called Segment which is pulled from a third-party application using a MySQL view (and is read-only), and finally a User model. Segment and message both belong to a user. The problem is that I nee...