ruby-on-rails

Rails not loading application.html.erb, instead loading view stubs

My application.html.erb is a classic file with the <%= yield %> statement. The expected would be if I went to domain.com/controller/action that it yields to the view in the appropriate directory. Instead, it's pulling up just the view (the correct view, but without the application wrapper). (There's no other layouts other than applica...

What is the recommended method of testing a JSON client-server api?

Edit #2: Does anyone have a good method of testing the "middle" of a client-server application where we can intercept requests and responses, fake the client or server as needed, and which provides self-documentation of the api? Cucumber might be a good solution in many cases, but it's not quite what I'm looking for. And this middle la...

what is ruby used for BESIDES rails?

Ruby on Rails has become a new competitive face in the server programming industry, along with php, asp.net, jsp, python, and a few others. But is ruby used for anything BESIDES rails? Does it owe all of its success to the rails framework? More questions here are tagged ruby-on-rails than ruby. However, I supposed PHP isn't used for that...

How can debug messages in erb be supressed in production mode

I want to print out some debug messages in my erb template when it is called in development mode, but not when it is called in production mode (i.e.) <%= debug variable_name %> However, this will be printed in any mode. I found I can do <% if logger.debug? debug variable_name end %> which seems to work. Is this the proper...

Limiting the view of certain page elements to only the owner of the profile?

I have a user model and a profile model. user has_one :profile profile belongs_to :user On the "show" view of the profile, there's an input field that only the owner of the profile should see. I currently have it limited to where only a logged-in user can see it, but I need it to go further and only appear visible to the user who owns...

mod_rails make: command not found

I'm setting up mod_rails on a Debian server but somehow something got screwed up (it wasn't me :P ). gem install passenger Building native extensions. This could take a while... ERROR: Error installing passenger: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb creating Makefile make sh: make: command not fo...

Disabling flash[:notice] to make page caching make sense.

We make heavy use of page caching, and sometimes pages get cached with a "You are now signed in" message. We can't disable the page caching for logged in users, or make it unique to them. So the only option I can think of is to disable the flash when a page is being cached, or visa-versa, disable caching when the flash is set. Idealy wit...

How do I patch a Rails 2.1 project with new vulnerability fixes

I've got an old Rails project with frozen Rails 2.1. I need to apply the patch from here http://weblog.rubyonrails.org/2009/9/4/xss-vulnerability-in-ruby-on-rails/ Using git-am doesn't work, I'm guessing because its expecting the git repo to have the rails folders in the root, which it doesn't. So how do I apply this patch? ...

Where to put data in an application that uses remote db through API?

Hi, guys. This is a general question, so I won't name which site's API I am refering to. OK, lets say the API gives me access to some objects (books/other products). I want to give my users the ability to "store" some of these objects in my app's db so that later they could "review" them again. My question is about the "store" and "re...

Friendly URL Question, with a Twist

I have a user model and a profile model. user has_one :profile profile belongs_to :user Because of this relationship, I pull up my profiles by calling the user id. So my urls look like this: website.com/users/[user_id]/profile I'm not sure if there's a solution to my problem. Here it is: I would like to display SEO friendly urls. I'...

How do you call a method from the view in raiis?

Lets say I did script/generate controller home And in the home controller made a the method.. def say puts "You are here" end How would I call that method in the index.html.erb? When learning ruby it just said to run the whatever.rb in the terminal to run what ever code you wrote within that file. Just curious on how that would wo...

How do the Ruby daemon

I want to do the Ruby daemon program. I need to call an action which I defined in the daemon program from my Ruby application. That daemon program may also be called from another application. I installed the Ruby daemon Gem and I did the test program. Can any one please give me the step by step sample. How can I achieve this? ...

Cucumber + Webrat + Selenium guide

Hello, I have been using Cucumber and Webrat for a while. I know need to start writing behaviour that involve AJAX interactions so I was thinking to use the Selenium adapter for Webrat. Can anyone point out a easy and updated step-by-step guide for installing and configuring selenium+webrat+cucumber? I would like to be able to mix javas...

Changing/Upgrading Existing Models

I starting building my app using nifty-generators for the user authentication because I'm new to Rails and it was the easiest approach. Now, we're looking to launch the app and I want to implement the popular Restful Authentication because we need some of the features it offers. I've never upgraded an existing model in this way, and I'...

Change the charset attribute in the html header

My whole app is serving stuff in utf-8, only one page (xml) should return a ISO-8859-1 page <?xml version="1.0" encoding="ISO-8859-1"?> Now, how can I change the header attribute in order to have the ISO-8859-1 served. The result of wget --save-headers http://79.125.52.185/kdb/jobs/jobs_ch is HTTP/1.0 200 OK ... Content-Length...

How to get the HTTP_HOST from Rails?

I need to set some server specific variables in a rails application that will run on at least two different servers. What is the best way to get the request's HTTP_HOST value in order to know what is the current server and set these variables accordingly? I'm using Apache 2 with Passenger. ...

ruby handsoap wiredump

Hi, How can see the wiredump of a soap using the 'handsoap' library? I use the on_before_dispatch hook, and right now I am looking at the SoapService variables to see where such a request might be stored. Hmm.. I should also check out invoke to see which var. is using.. Do you have a quick solution? :D Thanks ...

git - update to new branch of rails

I currently have a rails project running of a git tag v2.1.2, to get here id did git checkout v2.1.2 However there are now new fix's that have been applied to the 2.1 branch, how do I move to this branch rather than the tag? ...

Ruby on Rails AJAX file upload

Is there any easy way how to handle AJAX file upload in Rails? e.g. with a plugin ...

Rails routing with the URL hash (window.location.hash)

Is there a way to grab the URL's hash value (e.g. the "35" in /posts/show#35) in routes.rb, or in a controller? I'm under the impression that this is never sent to the server, but I just wanted to be sure. Thanks! Tom ...