ruby-on-rails

Encoding Ruby on Rails code?

Are there any applications out there that will let me encode my Ruby on Rails code so others can't read it? I plan on selling a few small applications, but I really don't want everyone knowing my code. Thanks. ...

What's the right way to define an anchor tag in rails?

It's obvious from the documentation (and google) how to generate a link with a segment e.g. podcast/5#comments. You just pass a value for :anchor to link_to. My concern is about the much simpler task of generating the <a name="comments">Comments</a> tag i.e. the destination of the first link. I've tried the following, and although the...

rails accessing value from facebooker hash/array

This is my first time using the facebooker plugin with rails, and I'm having trouble accessing user info. The website uses FB connect to authenticate users. I am trying to get the name of the university that the logged in user attends. When I use the command <%= facebook_session.user.education_history[:name] %>, I get an error "Symb...

How can all.js be created manually?

I'm using the function for caching multiple javascript files into one: <%= javascript_include_tag :all, :cache => true %> The way I understand it this creates the all.js file the first time a HTML file using it is generated. But if the app is configured to use an asset host on a seperate server that does not deliver HTML the file wil...

Is there something similar to 'rake routes' in django?

In rails, on can show the active routes with rake (http://guides.rubyonrails.org/routing.html): $ rake routes users GET /users {:controller=>"users", :action=>"index"} formatted_users GET /users.:format {:controller=>"users", :action=>"index"} POST /users {:controller=>"users", :action=>"cr...

Ruby on Rails - Optional Associations?

I would like to allow users to write comments on a site. If they are registered users their username is displayed with the comment, otherwise allow them to type in a name which is displayed instead. I was going to create a default anonymous user in the database and link every non-registered comment to that user. Would there be a bette...

debugkit for ruby on rails

I am a Cakephp developer that is currently doing some work in ruby on rails and one thing i use a lot in cakephp is debug-kit which allows me to see many things within the web page such as request information and variables available in the view. Is anything like this available for rails as i cant seem to find something similar. ...

Authlogic OpenID error: uninitialized constant OpenIdAuthentication::InvalidOpenId

Using authlogic 2.1.3, and authlogic-oid 1.0.4 I receive the following error as soon as rails hits a controller making a request to an OpenID provider: uninitialized constant OpenIdAuthentication::InvalidOpenId I also have the following installed: rack-openid (0.2.1) ruby-openid (2.1.7) rails/open_id_authentication plugin Gems in ...

Problem downloading large files with Rails, Nginx (with x-accel-redirect) and Apache(x-sendfile)

Hi to all! We have a big problem with downloads when the size is over than 1gb. We are using Rails 2.3.5, passenger 2.2.9 on Amazon EC2 2gb with 2gb of Ram and Fedora 10. Files are stored on /mnt/files, project is on /mnt/www/project We tried to send files with Nginx and x-accel-redirect and also Apache with x-sendfile. We can down...

one to one join with rails

I am new with rails and trying to understand its :has_many and :belongs_to functionalities. If I have 3 tables: Customers, Physicians, Addresses Each customer and each physician will have one address. So it is a one-to-one relationship. customer_id and physician_id will match address_id So if I want address of a customer with id 3. ...

Rails - Getting 500 server error through a browser but works through script/console. What gives?

OK, I've been chasing this for hours and I just can't figure it out. I have a Ruby on Rails application that I've deployed to my hosting provider DreamHost. I've created a new environment called "stage" and created a stage.rb file in the /config/environment folder and put the following line into my environment.rb # Be sure to restart ...

Rails Time Zone

I understand that default behavior of rails is to save the database records and any date/datetime related columns to UTC time. And we can control the display of date/datetime to the users with config.time_zone in environment.rb. So basically config.time_zone setting is to control the display, by which rails converts records from UTC to t...

rails 3.0: ActionController::Base render()

Can anyone explain where render() comes from in ActionController::Base? I managed to trace it down only that far: ActionController::Base includes ActionController::Rendering module where render() method is defined. This definition however calls to render() of the superclass. Superclass is ActionController::Metal. Which in its turn inhe...

How to modify the :confirm or add a new method to link_to UrlHelper?

I use this code to delete record: <%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> When I click the "Destroy", it will have an alert box prompt out and ask me to destroy or not. Can I modify the :confirm to an AJAX call? or can I add a :myConfirm in to the link_to tag to implement my own :myConfirm? T...

Storing a global hash in Ruby on Rails

I am looking at an application where I need to build out the user friend model as a graph structure. I need to go several degrees deep so using standard SQL in MySQL will not work due to the circular references. I have looked at the graph algorithms available and they involve loading the entire record set into a Graph object then doing...

check if value is a number ruby

Hello, I want to simply check if a returned value from a form text field is a number i.e, 12 , 12.5, 12.75 is there a simple way to check, especially if the value is pulled as a param. Thank you ...

Can I set the default string encoding on Ruby 1.9?

This might sound minor, but it's been driving me nuts. Since releasing an application to production last Friday on Ruby 1.9, I've been having lots of minor exceptions related to character encodings. Almost all of it is some variation on: Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 We have an ...

Rails: has_many with extra details?

While I'm not a complete Ruby/Rails newb, I'm still pretty green and I'm trying to figure out how to structure some model relationships. The simplest example I can think of is the idea of "recipes" for cooking. A recipe consists of one or more ingredients and the associated quantity of each ingredient. Assume we have a master list in th...

Action not found

Hi people. I want to show a simple HTML template, so I added a new empty action to my controller: def calulator end And created the view calculator.html.erb . Then added a link to it: <%= link_to 'Calculator', {:controller => "mycontroller", :action => "calculator"} %> When I click it my log shows the following error: ActionContro...

Rails: Ajax: Changes Onload

Hi. I have a web layout of a for that looks something like this <html> <head> </head> <body> <div id="posts"> <div id="post1" class="post" > <!--stuff 1--> </div> <div id="post2" class="post" > <!--stuff 1--> </div> <!-- 96 more posts --> <div id="post99" class="post" ...