ruby-on-rails

Editing a YAML file inside a Rails App

I'm trying to use a yaml config file as a very simple flat file db for a small rails app. The app has a single user, so I just need a way to store a username and password. The only thing is that I'd like to be able to edit the username and password while still inside the app and not require an app restart (so I can't load the YAML file...

will_paginate add image to page numbers

how can i add image to page numbers in will_paginate ...

Cucumber, Capybara validating HTML and testing JavaScript together fails

I've recently added html validation to my cucumber features. I'm using the gem be_valid_asset which works really well until Cucumber hits a @javascript flagged feature. This kicks in culerity (I've tried selenium for this as well) and then the html validation fails. The reason the validation fails is that both culerity and selenium ap...

De-authorizing a twitter OAuth application

We just finished implementing OAuth in our RoR application using the Twitter gem. The whole authentication process works perfectly and we are able to persist access tokens. We're wondering if there's a way for our de-authorize our access to twitter via our website. I realize we could just destroy the persisted token, but I'd also like to...

Rails ActiveRecord associations

I have an User model. How I can get all associations between the User model with other models ? I need to know the model names and the association type (1..1, 1..m, m..m ...) I don't want to use the db/schema.rb file ...

Rails: cattr_accessor and class variables

Running this code: module A def self.included(klass) klass.send(:cattr_accessor, :my_name) end def set_my_name_var @@my_name = 'A' # does NOT work as expected end def set_my_name_attr self.class.my_name = 'A' # works as expected end end class B include A cattr_accessor :my_other_name def set_my_other_...

In Rails, how to get the actual Query when an ActiveRecord query executes

Hi, I am using a simple query in ActiveRecord which does something like this. MyTable.find(:all, :conditions => {:start_date => format_time(params[:date]) }) I want to get the equivalent query that is executed in the background, perhaps using a puts statement or something similar to that. MySQL is my database. ...

URL rewriting in ROR

I am Amit. i am new to Rails. Please forgive me if ask any stupid questions. I have gone through this article. I am also suffering with the same problem. my website URL like this: locahost:3000/users/edit/30 I don't want to show the controller:users and action: edit. I want to Re-Write (rewrite) the URL or i want to maintain the URL...

Multiple orders in a single search via searchlogic

Is it possible to perform a multiple order_by while searching using Searchlogic? What I want to do is to search somehow like this: User.ascend_by_id.ascend_by_email I saw a corresponding ticket: on github project page. But still would like to hack on that and somehow perform this find. Is it possible? ...

How would I go about adding a simple menu to a Rails Application? (How to use yield :menu)

I want to add a menu to my First Ever Rails Application. Nothing too complicated. I've worked out that I should maybe reference it from application.html.erb, but after that I'm stuck. Here's what I've got so far (It's not much) <%= render :partial => "menu" %> If I'm rendering a partial call "menu" in application.html.erb, where do...

Current trend in testing models in a rails3 + datamapper application

Hi, What is the current trend for testing models in a Rails3+DataMapper application. I want to use RSpec but sorely miss the concise testing provided by shoulda macros. Question - Is there a way of getting the best of both worlds, ie. a nice dsl for testing and the brevity of shoulda macros, which can be used to test datamapper models. ...

Rails ActionMailer view text indentation problem

When i indent code in a mailer-view, i see the indentation in the sent (plain text-)mail, too. Is there a way to avoid this without writing my code without indentation…? ...

Passenger spawning new ruby instances on Ajax calls

I have some heavy perfomance issues with Passenger and ajax calls. It seems like every time I do an ajax call, a new ruby instance is started instead of using the one that responded to the original page request, making it really slow. The fact that multiple ajax requests can be made in just a few seconds doesn't make the situation better...

Not allowing space in password field when using authlogic

Hi, I am using authlogic for my user login functionality in my Rails app. But authlogic allows space in password and my application doesn't require this. So how can I do it? Thanks! ...

What does the 't()' tag mean in ruby on rails?

I came accross an opensource code in views, with a 't()' tag similar to html escape sequence, i.e h(). <%= f.label :password, t(:password, :scope => "activerecord.attributes.user") -%> I just want to know what t() means.. Anyone? ...

Lookup Gem or Plugin code packaged in a Rails3 application

In the Rails2 world, one could conveniently browse the code of plugins or gems packaged with the app. With Rails3, all the packaged gems are stored as .gem and hence are not browsable or searchable. Now I have to use 'bundle open [gem]' externally to browse gem/plugin code. Does anyone have a better technique to lookup or read gem/plugin...

Rails Postgres functional indexes

How I should enter my multicolum indexes which contain functions into schema.rb ? for example this DOESN'T work: add_index "temporary_events", ["templateinfoid", "campaign", "date(gw_out_time)", "messagetype"], :name => "temporary_events_campaign_tinfoid_date_messagetype" rake db:test:load rake aborted! PGError: ERROR: ...

acts_as_attachment and Capistrano problem

currently i am using acts_as_attachment and also using Capistrano. I want to store images in shared path rather than current path. I want set path during create action What should i do ????? Please code is more helpful Thanks in advance ...

format.js argument

Hi all, I've a question about passing argument with format.js There's my code (create method): respond_to do |format| format.js end I would like to know how can i get a variable value in my create.js.erb Thanks ...

rails' form_for, form_tag no longer working

I have multiple forms in my rails app that were working perfectly up until last night. With no actual modification of anything to do with forms, none of my form tags are even showing up in the HTML anymore. Is there any quick fix for this, or any known reason this would occur? Thanks! ...