ruby-on-rails

How do I install a rails plugin from git via ssh?

Installing a rails plugin using the git:// protocol is easy, you just type script/plugin install git://server.local/my_git_repo.git How do I install a plugin from a git repo hosted over ssh? When I type script/plugin install [email protected]:plugin.git I get "Plugin not found" I know it's not a git issue because the installer ...

Overriding primary key protection in Rails

Is there a way to overide the mass assignment protection on a model's primary key in Rails ? My seed.rb data won't load because of it. Update I've found including the following code in the model removes the protection def attributes_protected_by_default default = super default.delete self.class.primary_key default end N...

Having trouble getting started with Ruby on Rails

I'm wondering if someone can address some of the issues I am having? I create a rails app: rails myapp -d mysql cd myapp haml --rails . rake db:create:all Then I want to use a mysql client to create tables. Lets say users and customers. A customer is also a user so you have schema like this: users ---------------- id int, not...

Accessing a parameter within a plugin

I'm trying to modify the vestal_versions plugin to accept a parameter I set upon saving. This parameter will act as a new flag to determine when to create a revision upon updating. Currently it will always run upon update when a new revision is needed. Here is the affected area of unmodified plugin code: after_update :create_version, :i...

linking models ruby on rails

Hi I have 3 models: user, seller and cars i want the user to be able to choose a car from a seller and this gets added to the user's shopping list. I have something like this in my car controller: @user = User.find(params[:user]) @seller = Seller.find(params[:seller]) @car = @user.cars.build(params[:car]) but the seller isnt b...

Error on rake : The platform 'i386-mingw32' is unsupported.

I have Ruby 1.9 and rails 2.3.5 installed. After creating a rails app when I run rake db:create, I get i386-mingw32 error. I have both msysgit and cygwin on my windows machine. rake db:create (in C:/mydirectory) ==== UNSUPPORTED PLATFORM ====================================================== The platform 'i386-mingw32' is unsupported....

rails if object in an array

I need to check, if for each item in @line_items if it is in different array say @quote_items Controller: def index @line_items = LineItem.all @quote_items = QuoteItem.all end View: <% for line_item in @line_items %> <% if @quote_items.include?(line_item) %> line_item in quote item! <% else %> line_item NOT in q...

gem install error, index not found, ruby on rails

Problem: Cannot install any gem, any type. But I want to install riddle if that matters. When I run sudo gem install "gem_name" I get the following error: WARNING: RubyGems 1.2+ index not found for: RubyGems will revert to legacy indexes degrading performance. Bulk updating Gem source index for: http://gems.rubyforge.org/ What to d...

delayed_job: detecting when one instance already running in /etc/init.d/delayed_job

Hi all I've been trying to build a robust /etc/init.d/delayed_job script. Below is my naive attempt which is failing in the case of the daemon already running. #! /bin/sh ... # return 1 if already running do_start() { /path/to/current/script/delayed_job start if [ "$?" -ne "0" ]; then echo "delayed_job i...

Force Restful Authentication to login as a specific user (an admin function)?

I'm using Restful Authentication and I'd like to be able to log in as different users on our site to investigate issues they may be having ("see what they see"). Since all passwords are encrypted I obviously can't just use their passwords. So, how can I force a session to be logged in as a specific user? ...

Rails, Combine multiple controllers into one interface

In rails I am making a "blog" to help me learn. I was wondering how I could incorporate the editing, creating, and deletion of Users and Posts in my admin controller. I would also include deleting comments in there too. So far I have Users, Admin (basically just to login/control everything),Comments, and posts. So how could I combine all...

how do I ensure HTTP file upload (ie multipart etc) is transactional?

Hi, How can I ensure that if I am doing a HTTP file upload (e.g. say to update an existing file from v1 in my web application to v2) that it acts transactionally? That is in this case assume my web application has v1 of the file, but as part of the admin interface I can update this file. If whilst uploading v2 there is an issue with t...

What is Edge Rails?

What does "Edge Rails" mean? I found some hints on the interweb, but it's not clear, does it mean the latest Rails or Rails 2.2 or what? ...

config.cache_classes = true affecting type coercion with RubyDBI

Environment: Rails 2.3.2 DBI 0.4.1 DBD/ODBC 0.2.4 Scenario: I have a Rails app that imports most of it's data from external SQL DBs into the Rails SQL DB via regular batch jobs. Those batch jobs start by loading the Rails environment, then proceed to make direct database connections via RubyDBI. Once I connect, I run select statements t...

Problems Rendering View (ActionView::MissingTemplate ... Error) in Custom Plugin

I am trying to develop a plugin for Ruby on Rails and came across problems rendering my html view. My directory structure looks like so: File Structure ---/vendor |---/plugins |---/todo |---/lib |---/app |---/controllers ...

Uploading Pictures Ruby on Rails...

I am new to rails so sorry if this is easy. I am wondering the best way to upload pictures and display them in Ruby on Rails. I have a blog and would like to have the option of attaching a picture when creating a post. ...

how do I manually create POST parameters that are nested? (e.g. I'm creating the request in .Net to contact a Rails backend)

Hi, How do I manually create nested POST parameters for a http web request? I have a .NET C# client for which I'm creating a HTTP request to a Rails page. Everything is fine so far, however I've noted that the parameters I'm creating for the request (key/value pairs) are expected to be nested. I'm actually also having a hard time try...

RubyGems 1.2+ index not found for:

RubyGems 1.2+ index not found for: RubyGems will revert to legacy indexes degrading performance. Bulk updating Gem source index for: http://gems.rubyforge.org/ 1) I have reinstalled ruby and ruby gems from source 2) possible solutions that have not worked a) try adding different sources to gem sources b) updating gems, It's not out ...

Reddit clone in Rails with Rspec, resource_controller problem

http://github.com/samliu/rlinkset ^^ My code so far is pushed to there. Essentially, I'm using resource_controller and I don't really understand resource_controller. When I used scaffolding to create my Post model, I gave it fields like :integer parent #to say what level a post is at (which post ID is this post's parent) :integer user...

Is there a way to redirect to a specific page after a RESTful delete in Rails?

Lets say I have a message resource. Somewhere in the html I have: <%= link_to("Delete", message, :title => 'Delete', :confirm => 'Are you sure?', :method => :delete )%> Right after I delete it, it redirects me to the page where it lists all the messages. Is there a way to redirect to a page that I specify after the deletion? ...