ruby-on-rails

Why do values in the row I insert not match the values in the insert query?

I just can't understand why is my database (mysql) behaving like this! My console shows that the record is created properly (please, notice the "remote_id" value): Tweet Create (0.3ms) INSERT INTO `tweets` (`remote_id`, `text`, `user_id`, `twitter_account_id`) VALUES (12325438258, 'jamaica', 1, 1) But when I check the r...

multiple records using the select_tag

Update: To clear up confusion: by multiple records I mean multiple individuals at once. Each voter would have their own select__tag, this is the reason I want to pass the ID as a hash. I'm attempting to display multiple records, with each record displaying its own selection box. I would like to submit this form and pass a hash, having t...

Ruby - Get request body from incoming http call

Hi, I am receiving http requests to my rails application to a url /account/postback The body of this incoming request contains some json that I need to retrieve, how can I do this in ruby? Thanks, Andy ...

Setting default_scope according to some criteria

I'm trying to set default scope according to some criteria determined by ana ActionController before_filter. In controller: before_filter :authorize ... def authorize if some_condition @default_scope_conditions = something elsif another_condition @default_scope_conditions = something_else end end Inside...

Activerecord join search

Hi, i have two models: class Category has many :jobs end class Job belongs_to :category end So for sure i'm able to do c = Category.first c.jobs My question is: how can i find just categories that has at least one job? I just forgot to add today i'm executing it like: Category.find(:all).collect { |x| x if x.jobs.size > 0 }...

How to use these ruby based CSS stylsheet frameworks languages?

I read about many CSS related languages and tools which need ruby. What is the purpose of these languages and tool how these can save time and improve our CSS coding. What is the role in ruby language in these languages and tool. Will i have to install and learn ruby language to use these languages and tool. will i need ruby installed ...

Monkeypatch a model in a rake task to use a method provided by a plugin?

During some recent refactoring we changed how our user avatars are stored not realizing that once deployed it would affect all the existing users. So now I'm trying to write a rake task to fix this by doing something like this. namespace :fix do desc "Create associated ImageAttachment using data in the Users photo fields" task :us...

Local variable not being passed to partial template by render?

I don't seem to be able to pass a variable to my partial template in rails (2.3.5). My code is as follows; In the main view .html.erb file: <% f.fields_for :payments do |payment_form| %> <%= render 'payment', {:f => payment_form, :t => "test" } %> <% end %> and in the _payment.html.erb file: <%= t %> produces a wrong number of...

Using tarantula to test a Rails app

I'm using Tarantula to test a Rails app I'm developing. It works pretty well, but I'm getting some strange 404s. After looking into it, Tarantula is following DELETE requests (destroy actions on controllers) throughout my app when it tests. Since Tarantula gets the index action first (and seems to keep a list of unvisited URLs), it ev...

How to make facebox popup remain open and the content inside the facebox changes after the submit

Hi, I'm a jQuery total n00b. In my rails app this what happen: I'm on the homepage, I click this link: <a href='/betas/new' rel='facebox'>Sign up</a> A beautiful facebox popup shows up and render this views and the containing form: # /app/views/invites/new <% form_tag({ :controller => 'registration_code', :action => 'create' }, :id...

What is the best WYSIWYG for Rails - Ruby on Rails Blog

What is the best way to allow for the adding of images and embedding of video in the body:text field of a Ruby on Rails blog. I understand that I can use an attachment like Paperclip to add a photo to a record but I am wondering how to get images/vids into the actual body of the post. ...

MongoDB ruby dates

I have a collection with an index on :created_at (which in this particular case should be a date) From rails what is the proper way to save an entry and then retrieve it by the date? I'm trying something like: Model: field :created_at, :type => Time script: Col.create(:created_at => Time.parse(another_model.created_at).to_s and Co...

tag statistics with rails

I am using the plugin: http://github.com/karmi/is_taggable How can I perform simple statistics on my tags, e.g. what's the most used tag? which tags are not used, etc.? With SQL I would do something like: select id, count(*) from taggings group by taggable_id; But I am not seeing how to do this with the plugin. Thanks! ...

Continuous build integration tool for Rails and PHP?

Most of "multi-platform" CI tools I've seen are in the Java/.NET world, like TeamCity or Hudson. Is there a continuous integration tool that can handle both PHP and Rails projects? ...

Is there a definitive list of differences between the Ruby on Rails versions?

Is there a list of the differences between the various versions of Rails somewhere on the web? I'm working through an older book about Rails that uses Rails 1.2. I know there are other ways to learn Rails these days, but I thought it would be interesting to try and convert all of the exercises in the book to a more modern versions of Ra...

RubyGem version error: activesupport(1.4.4 not = 3.0.0.beta) (Gem::LoadError)

Hello, I want to use the last version of rails, in my Gemfile: gem 'rails', '3.0.0.beta3' When trying to start my server I get this error, do you know how I can fix this issue? $rails s /Library/Ruby/Site/1.8/rubygems.rb:777:in `report_activate_error': RubyGem version error: activesupport(1.4.4 not = 3.0.0.beta) (Gem::LoadError) f...

$.ajax + authentication + `@` in username

I am creating a web app which uses jQuery to authenticate: $.ajax({ url: "/session/create?format=json", type: "GET", dataType: "json", cache: false, username: $("#signin-email").val(), password: $("#signin-password").val(), success: function(data) { if(data.success) { success = true; } ...

How do I set default host for url helpers in rails?

I would like to do something like this config.default_host = 'www.subdomain.example.com' in some of my configuration files, so that object_url helpers (ActionView::Helpers::UrlHelper) produce link beginning with http://www.subdomain.example.com I have tried to search the docs but I did not find anytnig exept ActionMailer docs and htt...

When open-sourcing a live Rails app, is it dangerous to leave the session key secret in source control?

I've got a Rails app that's been running live for some time, and I'm planning to open source it in the near future. I'm wondering how dangerous it is to leave the session key store secret in source control while the app is live. If it's dangerous, how do people usually handle this problem? I'd guess that it's easiest to just move the st...

Rails, different routes for production app.

Well, maybe not just different routes. Here is the issue at hand, we have an app that we want to present the users with a "beta sign-up" form when the app is running in production, but we still want to be able to login, however in development the app should function normally. For example in development the app's root path would be the ...