ruby-on-rails

which technology is best for a Facebook application Ruby on Rails or C# and ASP?

hi, My friend and I want to write a Facebook application. We've narrowed down the list of possible technologies to Ruby on Rails and C# with ASP. Here are the pros and cons we've thought of. Cons: ASP - proprietary tools like Visual Studio etc. cost (lots of) money. We both don't know ASP (although we're not bad at C#). RoR - It's sc...

Noob Capistrano question on preserving upload directories

Hi all, In response to this blog post: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/ I have three questions: Can anyone confirm if the recipe there works? Where and how do I put that recipe? I have two folders need to stay across each revisions: /products and /public/images/site_images what recipe should I run...

how to call a helper method from controller in rails?

I created a helper method for some simple calculation. This helper method will just return an integer. I need the helper in both controllers and views. Unfortunately, it work well in views but not in controllers. I get the undefined local variable or method error. How can I fix it? Thanks all ...

Creating application using rails 2.3.5 and cassandra database

hi all, Pls guide me how to create rails application using rails 2.3.5 and cassandra database as rails 2.3.5 supports mysql, sqllite etc. I typed in the command prompt like this $ rails -d cassandra myapp Databases supported for preconfiguration are: mysql, oracle, postgresql, sqlite2, sqlite3, frontbase, ibm_db So pls help me in thi...

Simple IRB Question regarding Count

I have a class called Deal. Deal has vote_scores. I would like to see how many vote_scores are in Deal that are greater than 2. My guess : for vote_scores > 2 in Deal count end Doesn't really work :D Edit: I tried everyone's ideas. But note that : Deal.vote_scores Doesn't work because vote_scores is not an attribute ...

Rails CSV import, adding to a related table

Hi, I have a csv importing system on my app (used locally only) which parses the csv file line by line and adds the data to the database table. This is based on a tutorial here. require 'csv' def csv_import @parsed_file=CSV::Reader.parse(params[:dump][:file]) n = 0 @parsed_file.each_with_index do |row, i| next if i == 0 #...

Problem with Juggernaut and transparent wmode in Adobe AIR

Hi, I am trying to use juggernaut in Adobe AIR application, however the big issue with this is that the juggernaut flash file should have wmode parameter set to 'transparent'. This is a bit of a problem for juggernaut because it seems that it doesn't work with that parameter included. The interesting part is that it is working under Lin...

Determining a transaction fee before an order is processed

When users make credit card transactions on my web app, I'd like to include the transaction fee on the confirmation page before the user makes the order. The thing is, there are different transaction fees for different cards. Is there a way to determine a transaction fee from the card number? I'm using Rails and ActiveMerchant, but I fi...

Rails routes creating additional info in URL

Hi Everyone, Say if I have a model called 'deliver' and I am using the default URL route of: # Install the default routes as the lowest priority. map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' So the deliver URL would be: http://localhost:3000/deliver/123 What I am trying to work out, is ...

rails jquery slider and textile editor conflict

hello! i have a conflict between different jquery parts. i have a rails app and in there i have an internal area where admins can administrate the whole page and for that i put in a textile editor. outside i created a jquery slider for nicer overview. myTitle <%= javascript_include_tag 'jquery-1.4.2'%> <%= javascript_include_tag 'jq...

How do I assign a value from params, or session, whichever exists?

What is the "Rails-way" or the "Ruby-way" of doing the following: In my controller, I'm creating and instance of an Options class. It will be initialized with information in the params hash if the params hash exists. Otherwise, it will check the sessions hash for the information. Finally, it will initialize with defaults if neither p...

Errno::EEXIST (File exists - /path/to/image) Fleximage Gem Ruby on Rails

This happens when I try to create an image. How to capture this error and return an error message instead? (In other words, avoid this error from showing and instead add to error messages by errors.add_to_base) ...

Multi-model form problem

(I'm just learning rails so....) I have a photo model and a gallery model, habtm associations and a join table. I'm making a photo gallery. The gallery page has a title field and description field. User creates gallery title, then goes to the photo page and checkboxes each image they want in that gallery. I get the error "undefined meth...

Building and submitting an Active Record form by Ajax in Rails best practices?

Alright all you wonderful people out there; In my user interface I am building a form where users can add new records via Ajax. The users will be able add multiple records from the form (it will be cleared after each post) and I am wondering what conventionally would be the best way to setup the form. If I want to use form_for helpers ...

capybara selenium and JavaScript Destroy

I am using rails 2.3.5 and this is what I did. I have latest cucumber, cucumber-rails and capybara installed. rails demo cd demo ruby script/generate cucumber --rspec --capybara ruby script/generate feature post title:string body:text published:boolean ruby script/generate scaffold post title:string body:text published:boolean rake db:m...

Rails 3 CMS recommendation

I typically use rails models and typus as my CMS as it gives the most flexibility, plus typus is just brilliant. I'm starting a new rails 3 app, and typus isn't rails3 compatible yet. I'm looking around for a CMS that'll work in rails 3. I still want to be able to write my views in haml (rather than some custom templating lang) and need ...

rails howto compare datetime ?

hello, i have games in my sqLite DB with the attribute starting_date( t.date :starting_date). i would like to know all the games that have alreday started so i am using this lines of code: Game.find :all,:conditions=>"starting_date <= #{Date.today}" Game.find_by_sql("SELECT * FROM "games" WHERE (created_at < 2010-05-13)") the resu...

Caching in Ruby Gem, possibly not using Rails

I am rewriting an existing Ruby Gem to include caching. This is for a gem that is relatively commonly used, and accesses a large amount of static data on a web service. Currently, I have a small number of gem users doing a large number of accesses to the service that under normal conditions would be swamping / downing the service, and ...

authenticate_or_request_with_http_basic doesn't resolve on host but works on local

I am trying to use a method like this: def authenticate authenticate_or_request_with_http_basic do |username, password| username == "user" && password == "pass" end When I have it on my local machine it resolves fine, but on my server it just keeps asking for the password. I saw the site http://railsforum.com/viewtopic.php?id=1459...

Is there a ruby helper for making absolute links out of User Contributed links if they are not absolute?

For example, User adds this "iamsmelly.com". And if I add an href to this, the link would be www.mywebsite.com/iamsmelly.com Is there a way to make it absolute if its not prepended by an http:// ? Or should I revert to jQuery for this? ...