ruby-on-rails

Scaffolding does not create Routes.rb entry.

When using scaffolding in Ruby on Rails to build my controller, the scaffold is not adding a map.resource to the routes.rb file. I am having to do this manually to get the view to work. I'm merely following the blog demo they have you create in the tutorial so I'm not doing anything fancy. Shouldn't the scaffold be adding this automati...

Rails, Redmine, Mysql and SQL Server encoding problems

We had redmine working with mysql (and mysql works fine with utf8). Now we needed to migrate the database to SQL Server (latin1 is the default for us). The data acentuation is ok in SQL Server after the migration, but in the browser, data coming from the database is showing ? in the acentuation place. What could be the solution to show c...

Can paperclip read photo geometry off an S3 bucket?

I would like to read the geometry of a photo off of my S3 container. When it's on my local, this works : def photo_geometry(style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file photo.path(style) end But it doesn't seem to work when I switch my model over to S3.. Any recommendations? The bigger s...

Rails SQL query with % Wildcards works in SQLite but not PostgreSQL?

I have a query I'm using for a search with :conditions like this: :conditions => ['family_name LIKE ? OR given_name LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"] The query works fine locally on SQLite, but when I push to Heroku on PostgreSQL, only the first % works for both family_name and given_name. In other words, it wil...

Why won't my Ubuntu server install Rails 2.3.8?

I have an older Ubuntu server with a Rails app running on version 2.3.5 that I'd like to move to version 2.3.8. The server doesn't seem to know that there is an update available, no matter how many times I run a "gem update" or "gem update --system" or "update_rubygems" root@server:~# gem install rails -v 2.3.8 ERROR: could not find ge...

Testing models with relationships and callbacks in Rails with RSpec and Factory_Girl

I'm still a working on learning RSpec so I'm sorry if completely overlooked something... I'm writing a test for a recipe that has many ingredients. The ingredients are actually added as a percent (with a total % column on the formulation) so I want to make sure that the total column updates after every save. So right now my RSpec test...

How to validate recaptcha_tag with jQuery Validate?

I'm using jQuery validate for a contact form: $(document).ready(function(){ $("#contactFormid").validate(); }); and i'm using this rails plugin to generate recaptcha on my page recaptcha_tags :public_key => 'xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxx' , :display=>{:theme=>"white" } how do i get jquery validate...

get session data in rails

I'm new to rails coming from php, and I'm learning rails 3 with mongodb. I have got to the point where I have an html form post text to mongo, and i can create and login as a user. In the user login, i create a session with as created by nifty authenticate session[:user_id] = user.id now I'm trying to get that user_id from the sessi...

Ruby on Rails - access user defined lib functions in /lib/login_system.rb from app/views/layouts/_menu.rhtml

I have defined a function called is_logged_in? in a user defined library stored in the /lib directory, however when I try to use it in one of my views (in this case a _menu.html.erb view) I get a "undefined method `is_logged_in?' for #" error. I had assumed that if the method was available within the /lib directory then it would be acces...

google_maps plugin rjs problem

So I am using bhedana's google_maps plugin and have built a search for points that load on page render. I have all my points refreshing with page.replace_html 'locations', :partial => 'locations' but when I include page.replace_html 'map', :partial => 'map' in the same rjs file and have a partial that looks like <%= @map.to_html...

Rails: Unable to initialize has_many :through association from within unit test using model class name

I've been struggling to understand why I can easily use seeds.rb to create new Users and their default associations, but when running individual a unit test causes errors. I've tried to get around calling 'Role' as it causes errors in the unit test. I am relatively new to unit testing, but have been using Rails for several years alread...

Rails CKeditor Plugin Validation Errors

I'm using the Rails ckeditor plugin which includes swfupload. I've also installed the paperclip plugin to handle the actual files (though I don't think it's part of the problem). I've gotten everything working except that there's no message displayed to the user if it fails validation -- like a file is larger than the specified file si...

does url_for use to_param when building route

I'm having trouble getting url_for to render take to_param into account when choosing which route to use. I have two sets of routes that use the same model (Foo). If Foo.is_special, the url should map to /special/:action. If it isn't, it should map to /:id/:action. Because it's the same model, I'd like url_for to automatically know whic...

How can I get authlogic to use the Rails session instead of its own cookie?

I would like authogic to never set a user_credentials cookie, and only use the standard Rails session cookie. I see Session is included in Authlogic::Session::Session::Base after Cookies. If I log into my app and then delete the user_credentials cookie, I still stay logged in. So apparently authlogic is storing the credentials in both p...

Better solution than accessing routes in the Model?

So I know that you shouldn't use UrlWriter methods in a model, but I wasn't sure what a better way to handle my current situation is. Basically, I want to allow a User to post something to his facebook feed, and want to write a post_to_fb_feed(object) method in class User. Now, the URL of what is actually posted depends on the object, s...

Restrict logged in user in list

hi, In the below code i want to Restrict display loggedin user in list of users index <div id="users"> <% for user in @users %> <div class="user"> <p> <strong><%=h user.username %></strong> <%= link_to "Add Friend", friendships_path(:friend_id => user), :method => :post %> <div class="clear"></div> </p> ...

How to asynchronously receive data into a Rails app from an iPhone app?

Hello everyone, A large part of a project I'm working on now deals with sending certain messages, which can easily and preferably be XML, from an iPhone app to a Ruby On Rails app. The webapp will have to instantly show these messages, so reloading the page isn't really an option. I've been unable to find any info re: creating this sor...

Things to consider while using session in Rails

Hi, While using session in Rails, what are the things that I have to be careful in perspective of security.? ...

Accessing id in a just built object

Hi, I have a rails app where I have clusters and users in a belongs_to has_many relationship. In the cluster_controller create method I write: @cluster = @current_user.clusters.build(params[:cluster]) now I want to run some commandline script: output = `echo cluster#{@cluster.id} > /tmp/out` ...rest of function here I also tried...

Nested Routes with has_one in rails

G'day guys, Having a bit of an issue with Rails routes, at the moment. Have a top resource: /Customer/ which itself has only one /Quote/ resource Quotes can have both first_resources and second_resources which are collections of resources associated with the quotes Building the route, though how do I nest multiple routes under a has...