ruby-on-rails

TextMate can't find my RSpec gem in opt (from macports)

I know I've had this problem before so I'm really frustrated. I've got the Ruby RSpec bundle installed for TextMate, but when I Run Behaviour Description or Run Focused Example I get this wonderful error: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827: in `report_activate_error': Could not find ...

Sending Facebook notifications

Hey i have a little facebook iframe application written with rails and the facebooker plugin. I can loop through the users friends and see whether they also have this application. To do this I use a fql qeury, and my own html (no fbml). Now i want to create a button right beside every friend who doesn't have this app, that sends an invit...

My helper methods in controller

My app should render html, to answer when a user clicks ajax-link. My controller: def create_user @user = User.new(params) if @user.save status = 'success' link = link_to_profile(@user) #it's my custom helper in Application_Helper.rb else status = 'error' link = nil end render :json => {:status => status, :li...

ruby on rails ferret search:.only 10 records are getting from table

ruby on rails ferret search:.only 10 records are getting from table.For pagination i did it ,but only 10 records are getting even though there exists more records satisfying the search condition.if any of you know how to solve this,please reply. no limit is given.if it is not a ferret search all records are getting from table , and pagin...

Rails.cache throws "marshal dump" error when changed from memory store to memcached store

If I set this in my environment config.action_controller.cache_store = :mem_cache_store ActionController::Base.cache_store will use a memcached store but Rails.cache will use a memory store instead: $ ./script/console >> ActionController::Base.cache_store => #<ActiveSupport::Cache::MemCacheStore:0xb6eb4bbc @data=<MemCache: 1 servers,...

even small file upload stops activity on apache/rails

on my rails(2.3.5) app(currently 50-70rpm, maximum response time around 0.7s), uploading even 700k file(using paperclip plugin) locks up the server for web requests for everyone for 2 minutes! (other apps on same server work normally) does anyone have a clue why that might be happening? i am using some mysql transactions which lock the ...

"cucumber: command not found" error on command line; "rake cucumber" works fine though

Just updated my cucumber gems on my system and have run into an issue with running my tagged cucumber features. The "cucumber" command no longer works on my command line. -bash: cucumber: command not found Initial thought was that my $PATH wasn't set up in my bash_login properly. All seems correct here though, i think: echo $PATH /op...

How to pass a Javascript variable to Rails Controller ?

Hi Inside my index.html.erb <script type= "text/javascript"> var msg = "Hello World" ; </script> i need pass this var msg to my controller say get_variable() method in my Post controller. Edit : get javascript variable msg in same index.html.erb as ruby variable Thanks in Advance ...

Rails Layout Rendering with controller condition

I don't know what's the best way to doing this. On my application.html.erb I define a header div. My default controller ( root ) is a homepage controller. And I wish that if I'm at index of the homepage the header is rendering with some content, but all other controllers render another content inside that header. How can I make a con...

PHP: Problem cURLing a Rails page

Why am I having problem curling on this page: https://traderydex.com/login/index.rails Here's my code: <?php $url = 'https://traderydex.com/login/index.rails'; $data = array('UserId' => 'username', 'Password' => 'p@$$wod'); $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "...

Rails, use the content of file in the controller

Hi, I've a file in the config directory, let's say my_policy.txt. I want to use the content of that file in my controller like a simple string. @policy = #content of /config/my_policy.txt How to achieve that goal, does Rails provide its own way to do that? Thanks ...

Rails and date: get profiles with related ages

Hy, I have a profile x, that has a born_date and then i want to get all the profiles that has more or less 5 years. If profile x has 20 years, i want every profile that has between 15 and 25 years. Here i need some date calculations and i dont really know how to do it. You have some ideas? ;) ...

Invalid AuthenticityToken everywhere

I have a rails app that I just deployed which is generating Invalid AuthenticityToken errors anywhere a form is submitted. The app uses subdomains as account names and will also eventually allow for a custom domain to be entered. I have an entry in production.rb to allow for cross-domain session handling. The problem is that you can...

Missing Required Gems - javan-whenever and cron job in rails

Hi, I have finally managed to get javan-whenever gem working on my site5 server, and updating the crontab is quite easy, however whenever a cron job is run with the code that is generated, i get a "missing required gems" error where it lists about 8/10 of my gems. Has anyone else had this problem? If so, what would the solution be. T...

Use openinviter with Rails or Java?

Hi, does anyone know if I can connect my self hosted Openinviter from within a Ruby on Rails or Java app, e.g. through an API? I couldn't find anything in the docs there and the forum isn't very active. It seems to be a good alternative to octazen, who have recently been bought by facebook and won't update their libs anymore. ...

Dynamic Custom Fields for Data Model

I am in the process of creating a dynamic database where user will be able to create resource type where he/she can add custom fields (multiple texts, strings, and files) Each resource type will have the ability to display, import, export its data; I've been thinking about it and here are my approaches. I would love to hear what do yo...

Where to put files that will be read in a Rails app?

I'm developing a Rails application and within that application I developed a Rake task that will read entries from a file and store them into the DB. Producing the code was no problem, but I'd like to know, where do I place the file that is read? Is there a convention for that, if yes, what is it? I know I could have used the seed.rb fi...

What's causing "NoMethodError: undefined method `include?' for nil:NilClass"

I have a Book model in my Rails application, with various properties (aka columns in the book db table). One of these properties is "ranking". Recently, may app has started to throw NoMethodError: undefined method 'include?' for nil:NilClass for the following code: def some_method(book, another_arg) return book.ranking unless book.ra...

Rails after_create callback can't access model's attributes

I can't access my model's attributes in the after_create callback... seems like I should be able to right? controller: @dog = Dog.new(:color => 'brown', :gender => 'male') @dog.user_id = current_user.id @dog.save model: class Dog < ActiveRecord::Base def after_create logger.debug "[DOG CREATED] color:#{color} gender:#{gender} ...

Rails 3.0.0.beta2 problem with Rails::Generators::GeneratedAttribute

So I am trying to use the rails3 branch of Nifty Generators by Ryan Bates. Now I've used this gem before with beta1 and its worked, but after upgrading to beta2 I've been getting a very wierd error. lib/generators/nifty/scaffold/scaffold_generator.rb:35:in `block in initialize': uninitialized constant Rails::Generators::GeneratedAttrib...