ruby-on-rails

problem installing rails3.0

Tried the link http://railscasts.com/episodes/200-rails-3-beta-and-rvm gokul@gokul-laptop:~$ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] gokul@gokul-laptop:~$ mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install The program 'git' is currently ...

Removing a pattern from the beggining and end of a string in ruby

So I found myself needing to remove <br /> tags from the beginning and end of strings in a project I'm working on. I made a quick little method that does what I need it to do but I'm not convinced it's the best way to go about doing this sort of thing. I suspect there's probably a handy regular expression I can use to do it in only a cou...

NoMethodError: undefined method `has_attached_file'

Paperclip produces this error, after checking out the plugin's rails3 branch. My Gemfile has following line: gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3' And the error message is: NoMethodError: undefined method `has_attached_file' for #<Class:0x2a50530> ...

Hobo with authlogic user session problem

Just a day into hobo now I think it's great but got a small problem. User session are running with hobo, can't get current_user. I can login in to my site as normal without adding the line session[:user] = user.typed_id def create @user_session = UserSession.new(params[:user_session]) session[:user] = user.typed_id if...

What is the subject of Rspecs "#its" method

When you use the its method in rspec like follows its(:code) { should eql(0)} what is 'its' referring to. I have the following spec that works fine describe AdminlwController do shared_examples_for "valid status" do it { should be_an_instance_of(Api::SoapStatus) } it "should have a code of 0" do subject.code.should eq...

What are people's opinions vis-a-vis my choice of authorization plugins?

I'm slowly but surely putting together my first rails app (first web-app of any kind in fact - I'm not really a programmer) and it's time to set up a user registration/login system. The nature of my app is such that each user will be completely separated from each other user (except for admin roles). When users log in they will have thei...

Rails reusing form view on edit, but setting some fields readonly

I've a model that the user isn't allowed to update most fields on after the initial creation. I've seen the :readonly HTML attribute I can tack on all field helpers, but doing conditionals on all fields feels... icky. I'm not using anything special for creating my forms at the moment, just plain HAML. Anyone know of a better way of do...

How to verify the SSL connection when calling a URI?

Hello, I am developing a web application that is authenticated using CAS (A single-sign-on solution: http://www.ja-sig.org/wiki/display/CAS/Home). For security reasons, I need two things to work: The communication between CAS and my application needs to be secure My application needs to accept the certification coming from CAS, so tha...

Mocking view helpers with rspec-rails 2.0.0.beta.8

I am trying to mock a view helper with rspec2. The old way of doing this throws an error, complaining the template object is not defined: template.should_receive(:current_user).and_return(mock("user")) Am I missing something here, or is this not implemented in rspec2 (yet)? ...

Git + Capistrano = Automatic Release Notes Generator ?

We use git (github) and capistrano (like 99% of the Rails shops out there) to deploy our app to production. What I'd like to do is, after every cap * deploy generate a text file containing all the git commit comments since the last deploy. I can then take that list of commit comments, clean it up, and put it somewhere for consumption. ...

Command output in rails console: Explanation of unwanted output?

I am working with the rails console, and some models. I am running things like: Model.find(:all).each do |x| p x.name end which is nice, this lets me see all the values of a specific column, but after it prints those lines, it prints out the whole model. Why does it do this? How can I stop it? ...

RSpec + Machinist. auto_increment issue

By default, "rake specs" re-creating my test database, using environment's one. It removes all the data, but not the the auto_increment. So when i'll try to make a new user: User.blueprint do login { Sham.login } email { Sham.email } end # the test: user = User.make user.id.should == 1 It says, that ID was 1800 (auto_increment w...

Passenger: RailsBaseURI case sensitive?

I used Passenger to deploy a RoR app to a sub URI on my domain. The problem I'm facing is that the sub URI seems to be case sensitive. Navigating to http://mydomain.com/RailsApp resolves fine. However, if I go to http://mydomain.com/railsapp, http://mydomain.com/railsApp, or any other variation, I get a 404 error. How can these requests ...

Ruby to_json :methods arguments

I am using the to_json method on an object, and trying to get the :methods argument to work. I have a method on my model (Drop) called is_favorited_by_user?. This method takes an argument of the current_user, and then checks to see if the drop is favorited by the user. How can I pass this argument through the to_json method. render :jso...

rails using jruby 1.5 - slow!!

Hi! I'm currently using passenger with ree 1.8.7 in production for a rails 2.3.5 project using postgresql as a database. ab -n 10000 -c 100: 285.69 [#/sec] (mean) I read jruby should be the fastest solution, so I installed jruby-1.5.0.rc2 together with jdbc postgres adapter and glassfish. As the performance is really poor, I also sta...

Inserting variable into routes - map.resources :posts, :as => X - is this possible?

Ok, so I am working on a blog application of sorts. Thus far, it allows for a user to sign up for their own account, create posts, tags, comments, etc. I have just implemented the ability to use www.myapp.com/brandon to set @user to find by username and therefore correctly display the users information at each url. So when you go to ww...

What is the best way to setup my tables and relationships for this use case?

1)A user can have many causes and a cause can belong to many users. 2)A user can have many campaigns and campaigns can belong to many users. Campaigns belong to one cause. I want to be able to assign causes or campaigns to a given user, individually. So a user can be assigned a specific campaign. OR a user could be assigned a cause and...

How to save copy of outgoing email in IMAP "Sent" box using ActionMailer?

When I use my regular client and send email through SMTP for an IMAP account, that outbound email gets saved in the IMAP "Sent" box. How can I have the same behavior when I send email using Ruby on Rails ActionMailer? ...

Mysql question: is there something like IN ALL query?

For example this query: SELECT `variants`.* FROM `variants` INNER JOIN `variant_attributes` ON variant_attributes.variant_id = variants.id WHERE (variant_attributes.id IN ('2','5')) And variant has_many variant_attributes What I actually want to do is to find which variant has BOTH variant attributes with ID = 2 and 5. Is t...

Help with Associations in Rails 3

Ruby: 1.9.2 Rails: 3.0beta3 I need some help with associations in Rails 3. I have the following models (see excerpts below): School, State, SchoolLocale The schools table has the following fields: id, name, state_id, school_locale_id The states table has the following fields: id, abbr, name The school_locales table ha...