ruby-on-rails

Storing/querying binary sequences and searching with masks

I've found a good way to store some data in the database with a binary sequence, like 0b0101000 and find rows that give a positive result after applying a mask. For exemple : SELECT (0b0101010 & (1<<3 | 1<<5))>0; allows me to get rows with the 3rd or 5th bit on, no matter if the others bits are on or off. The problem is when I want to ...

Rails Using Devise to show Online users

Hello I would like to show my online users in a Who's online module. I'm using Devise to manage my users. I searched everywhere, but I don't have any idea to manage it. Do you have a clue? Thanks in advance ...

Handling odd request formats with Rails

We have a site that is receiving requests for URLs in odd formats (for instance :formats=>[:"application/youtube-client", :"/"]) However, as we don't have this in the app (it's all HTML) how do we handle these requests without returning an error or suchlike. Is there any way of defaulting everything to HTML? ...

Updating nested params not working.. whats wrong?

Im trying to update some nested params from a form. I can see that the parameters im getting from the form is correct, however the database dont get updated. the view <% form_for @order do |f| %> <% f.fields_for :itemgroups do |ff, i| %> <% ff.fields_for :items do |fff| %> <%= ff.text_field :text, :id => "textField", :disab...

Scopes with has many through association

I have 2 models Widget and Feature which have a has many through association using WidgetFeature model. class Widget < ActiveRecord::Base has_many :widget_features has_many :features, :through => :widget_features end class WidgetFeature < ActiveRecord::Base belongs_to :feature belongs_to :widget attr_accessibl...

Separation of concerns dilemma in Rails

I'm trying to make logging for my rails app and have some dilemmas over philosophy used in rails. My app has Link model which has_many Hits: class Link < AR::Base has_many :hits end class Hit < AR::Base belongs_to :link end Now each time the link is being hit, I call hit! method to record a request on the link (to keep the contro...

A bridge between an SSH and an S3 bucket for file transfers..

I have 17 gigs of images directly on my server that I would like to move to S3. First I tried to scp them and it it took roughly 9 hours, so that doesn't seem to be a good idea to use those because other people have probably touched those images since then. I'm thinking something similar to rsync, but rsync wouldn't work because I can't ...

Are there any good documents for mongo_mapper?

After some searches, I found the documentation of mongo_mapper is poor. There is only a short readme on GitHub, only one article in http://mongomapper.com, and just a list of classes in the RDoc. I know there is a good screencast at http://railscast.com, but I want some more good documents about how to using mongo_mapper. Are there an...

Devise with OpenID in Rails3 beta4 but raise [undefined method `apply_schema'] error

Hi friends, I have use devise_openid_authenticatable to support OpenID with devise in rails3 beta4. But when I run rake db:migrate, it occurs [undefined method `apply_schema'] error.like this: == DeviseCreateUsers: migrating ============================================== -- create_table(:users) rake aborted! An error has occurred, all...

Rails-way of structuring admin/user/public controllers

Hi there, A fictitious Rails app has the following resources: Photographers Images Comments A Photographer has many Images, that have many Comments Each photographer has a login and is able to view, upload, edit and delete their images, comments as well as their own profile. An administration interface is available and can edit bot...

Change default find method in rails

I've read this somewhere but I can't find it now. I'm trying to change the default "find" method on a model from the id to for example the name. So when I map resources to a model it uses the the name instead of the id. I don't remember if this was a parameter in the resources command in the route file or if it was something you added ...

Making functional tests in Rails with Devise

After 3 years of procrastination today is the day that I start testing my Rails apps. My first step is to fix the failing tests in my Rails 3 beta4 app. My last 3 failing tests have to do with the devise gem and its authenticate_user! method in a before_filter at the top of my controller. You'd earn great karma by helping me out with t...

Posting data between Rails app

Ok so here's the big picture, I have 2 sites, call them SiteA and SiteB. SiteA sort of serves as a master site when it comes to ecommerce transactions (We only have one account with our Credit card processing company, so successful/declined transactions get redirected to SiteA) So a user logs on to SiteB, goes through the buying proces...

Ruby on Rails: How do I pass @variables to an iframe? (Goal: Sandboxing part of a page)

So, i figured, that I'd have to do this with the URL, rather than rails magic, cause I haven't found anything on iframes and rails... <iframe src="/content_container/<%@object.id%>?page=<%@page%>" width="665" height="85%" frameborder="0"> but... when i get an error: it show this Request Parameters: {"page"=>""} Any ideas? or a ...

Remove model from Devise urls

How do I remove the model name from Devise urls? Ie users/sign_in -> /sign_in users/sign_out -> /sign_out users/registration/sign_up -> /sign_up users/registration/edit -> /edit ...

Rails3 routing: Resource with namespace

Hi! Is it possible to define a namespace parameter when defining my routes, like this: resource :account, :namespace => :account do resources :comments end So /account/comment calls Account::CommentsController instead of just CommentsController. Just as a note, the :namespace-option above does NOT seem to work. I can of course ...

no such file to load -- rspec/autorun (LoadError)

attempting to use rspec2, rails3, and autotest. When running autotest I get stuck with the following: loading autotest/rails_rspec2 style: RailsRspec2 -------------------------------------------------------------------------------- ... ...bin/rspec:2:in `require': no such file to load -- rspec/autorun (LoadError) Looks like a path ...

jQuery error "missing ; (semicolon) before statement <script type="text/javascript">\n " after Ajax request. Any idea?

Hello there, I am stuck with my Rails application where I use JQuery to post/get ajax requests and I have this following error (found by using Firebug). missing ; before statement <script type="text/javascript">\n I am using the JQuery ajax method to post like this: function day_on_change() { jQuery.post( "/times/add"+ "?...

How to set-up jquery-ui autocomplete in Rails

Hi all. I need some help on how to implement a jquery-ui autocomplete in my Rails app. I want to add autocompletion to a text field where the user can enter in a customer name. As there can be hundreds of customers, I will need to pull the suggested auto-completion values 'remotely', as in, from a table (at least this is what I understa...

Do i login using cookies or sessions in a login system?

Do i login using cookies or sessions in a login system? I've seen examples using sessions and cookies so i am confused! Can someone please explain this? What do most sites use? love to know! Thanks in advance;-) ...