How to escape string in Ruby to protect against SQL Injection? (No Rails)
I just wanted to know how can we escape an SQL query (string) in Ruby to prevent SQL Injection. please note I am not using Rails framework. Thanks. ...
I just wanted to know how can we escape an SQL query (string) in Ruby to prevent SQL Injection. please note I am not using Rails framework. Thanks. ...
I am learning Ruby on Rails so I'm sure I'll find this out sooner or later. Why would the scaffold method be deprecated in version 2 of Rails? ...
In a Rails app sometimes you use a redirect in an action... redirect_to :controller => 'sessions', :action => 'new' I wonder if that's bad though because it sends back a 302 status to the browser and then the browser makes a whole new request. It's an additional back-and-forth. Would it be better to just render a template? render :t...
Has anyone had any success in getting Webistrano running on Windows. Everywhere I have read says it wont run on Windows, but isnt that kinda the point of using Ruby? ...
Hi All, I have a rails app and a separate druby process. This process gives me some methods, and at the first line of each druby's method there is a call to ActiveRecord::Base.establish_connection, where the db_name depends on a param set by the rails application. Sometimes the process is getting the wrong database name and I think it ...
Im struggling to find good material about developing web applications in Ruby without using a framework such as Rails or Merb in the usual places (I've already spent a while on Google, Safari books online and stackoverflow looking!). I have nothing against the frameworks at all; just my intended architecture is a little different and so ...
Playing with sinatra, I'm stuck on a little problem : when I use params with slashes, it confuses the router engine. So is there a nice way to handle this kind of param without having to encode it ? The code looks like get 'add/:url' do #.... end And I intend to get something like /add/http://sctackoverflow.com/ working ...
Is there an easy way to display powers in PDF generated using the Ruby PDF::Writer library? I realize that I can just print the exponent a bit higher than the base number, however I thought maybe there is some easier way to do this... such as a markup tag of some sort. Basically, I want to cleanly display x**-2. Thanks in advance! ...
I'm getting a failing test here that I'm having trouble understanding. I'm using Test::Unit with Shoulda enhancement. Action in users_controller.rb I'm trying to test... def create unless params[:user][:email] =~ / specific regex needed for this app /i # ... render :template => 'sessions/new' end end Test... context 'on...
I'm trying to extend the Method class along the lines of: irb(main):008:0> class A irb(main):009:1> def a irb(main):010:2> puts "blah" irb(main):011:2> end irb(main):012:1> end => nil irb(main):013:0> class Method irb(main):014:1> def aa irb(main):015:2> p "hi" irb(main):016:2> end irb(main):017:1> end => nil irb(main):018:0> f = A.new ...
I have a Ruby script in my Rails app that I use to load some data from Twitter. In the future I will make it an automatic background process, but for now I run it manually like: ruby /lib/twitter/twitterLoad.rb In order to use the Rails model classes and such, I have the following as the top line of the script: require "#{File.dirn...
Working with Test::Unit and Shoulda. Trying to test Users.create. My understanding is that Rails forms send params for an object like this: user[email] Which turns into hash in your action, right? params[:user][:email] OK, so in my test I've tried... setup { post :create, :post => { 'user[email]' => 'invalid@abc' } } and setup ...
I have the following Rails link generating code (I have removed potentially 'industry secret' stuff, sorry for the odd names, but the length of variable names and values match) <%= link_to_remote "FOUR", :method => "get", :url => {:action => "testing01_four_log_info", :fourth_name => "LA1", :testing01_num => "123"} %> This code gener...
I'm having some performances issues in a rails project (running on rails 2.0.5), for example in my user administration pages. my user model has many relations (details, addresses, roles...) who get loaded with eager loading. That creates really huge SQL queries, for some cases, it takes almost a minute to load 30 users. On the other han...
Let's say that in the controller I get an array of objects from the database this way: @statuses = TwitterStatus.find(:all, :order => "tweet_id DESC", :include => :twitter_user) Also I have the following loop in the view: <% unless @statuses.nil? -%> <ol> <% for status in @statuses %> <li><%= h(status.text -%>/li> <% end -%> </ol...
I have a large database of users (~200,000) that I'm transferring from a ASP.NET application to a Ruby on Rails application. I don't really want to ask every user to reset their password and so I'm trying to re-implement the C# password hashing function in Ruby. The old function is this: public string EncodePassword(string pass, strin...
I can't seem to compile ironruby in ruby 1.8.7. I always get this error: no such file to load -- windows/path Does this mean that ironruby is not compatible with ruby 1.8.7? ...
I have a User.create action that provisionally registers a new user and sends an email with a generated password. What is the most Rails-like way to complete that action? I want to do everything exactly right from now on. No more nonsense. This time I'm serious. I'm thinking these are the options... Create a view called login_email_se...
How do you modify a model you've generated using modeling? For example, the model myModel originally had columns a, b and c, but I now want to add column d. ...
I'm constantly doing this puts “The temperature is “ + String(temperature) + “.” in my debugging code, and another option is to use interpolation puts “The temperature is #{temperature}.” is there any less cumbersome way to do this? Edit: This is just for debugging, if that matters. ...