Search Results

Search found 297 results on 12 pages for 'rails3'.

Page 5/12 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Access Rails 3 Session from Rack?

    - by viatropos
    I was able to do the following in Rails 2.3.5 to access attributes that I set on the session from within my Rails app. Now in Rails 3, env["rack.session"] is nil. How do I do the same thing in Rails 3? class CallbackFilter def initialize(app) @app = app end def call(env) unless env["rack.session"][:oauth_callback_method].blank? env["REQUEST_METHOD"] = env["rack.session"].delete(:oauth_callback_method).to_s.upcase end @app.call(env) end end

    Read the article

  • MongoDB, Carrierwave, GridFS and prevention of files' duplication

    - by Arkan
    I am dealing with Mongoid, carrierwave and gridFS to store my uploads. For example, I have a model Article, containing a file upload(a picture). class Article include Mongoid::Document field :title, :type => String field :content, :type => String mount_uploader :asset, AssetUploader end But I would like to only store the file once, in the case where I'll upload many times the same file for differents articles. I saw GridFS has a MD5 checksum. What would be the best way to prevent duplication of identicals files ? Thanks

    Read the article

  • Big Ruby/Rails 3 problems

    - by Oluf Nielsen
    Hey i got an White Macbook and, has to go in 10 hours to a Conf. and i having a lot of problems.. First, i wnated to have rails 3.. so i used MacPorts to install Ruby 1.8.7, it worked well ;) So now i was thinking i should nstall rails 3.. but no, no!.. it says.. $ sudo gem install rails --pre ERROR:   Error installing rails:                  activesupport requires Ruby version = 1.8.7. So what can i do? i have 1.8.7 !...

    Read the article

  • Rails 3 - Category Filter Using Select - Load Partial Via Ajax

    - by fourfour
    Hey. I am trying to filter Client Comments by using a select and rendering it in a partial. Right now the partial loads @client.comments. I have a Category model with a Categorizations join. This all works, just need to know how to get the select to call the filter action and load the partial with ajax. Thanks for you help. Categories controller: def filter_category @categories = Category.all respond_to do |format| format.js # filter.rjs end end filter.js.erb: page.replace_html 'client-not-inner', :partial => 'comments', :locals => { :com => Category.first.comments } show.html.erb (clients) <% form_tag(filter_category_path(:id), :method => :put, :class => 'categories', :remote => true, :controller => 'categoires', :action => 'filter') do %> <label>Categories</label> <%= select_tag(:category, options_for_select(Category.all.map {|category| [category.name, category.id]}, @category_id)) %> <% end %> <div class="client-note-inner"> <%= render :partial => 'comments', :locals => { :com => @comments } %> </div><!--end client-note-inner--> Hope that makes sense. Cheers.

    Read the article

  • Ruby DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1.

    - by user297221
    Hi guys. I am using rails 3 and at the moment i am writing tests for my application. I get this weird deprecation warning: DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from at /Users/jeljer/Dropbox/webCMS/config/environment.rb:6) Of course my routes file is this: WebCMS::Application.routes.draw do #... end but no luck. If I look at the place what it is pointing to in my enviroment.rb: WebCMS::Application.initialize! I did a gem cleanup without any luck. Does anybody have an idea? ps. i am using rvm with ruby 1.9.2

    Read the article

  • Uploadify and rails 3 authenticity tokens

    - by Ceilingfish
    Hi chaps, I'm trying to get a file upload progress bar working in a rails 3 app using uploadify (http://www.uploadify.com) and I'm stuck at authenticity tokens. My current uploadify config looks like <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $("#zip_input").uploadify({ 'uploader': '/flash/uploadify.swf', 'script': $("#upload").attr('action'), 'scriptData': { 'format': 'json', 'authenticity_token': encodeURIComponent('<%= form_authenticity_token if protect_against_forgery? %>') }, 'fileDataName': "world[zip]", //'scriptAccess': 'always', // Incomment this, if for some reason it doesn't work 'auto': true, 'fileDesc': 'Zip files only', 'fileExt': '*.zip', 'width': 120, 'height': 24, 'cancelImg': '/images/cancel.png', 'onComplete': function(event, data) { $.getScript(location.href) }, // We assume that we can refresh the list by doing a js get on the current page 'displayData': 'speed' }); }); </script> But I am getting this response from rails: Started POST "/worlds" for 127.0.0.1 at 2010-04-22 12:39:44 ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): Rendered /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms) Rendered /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (6.6ms) Rendered /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (12.2ms) This appears to be because I'm not sending the authentication cookie along with the request. Does anyone know how I can get the values I should be sending there, and how I can make rails read it from HTTP POST rather than trying to find it as a cookie?

    Read the article

  • Rails 3 plugin - Generate a custom migration file

    - by moshimoshi
    Hi, On this article http://www.themodestrubyist.com/2010/03/16/rails-3-plugins---part-3---rake-tasks-generators-initializers-oh-my/ we can see the following codes which allow to invoke a migration file: class ActsAsTaggableOnMigrationGenerator < Rails::Generators::Base invoke "migration", %(add_fields_to_tags name:string label:string) end The command looks like: $ rails generate acts_as_taggable_on User invoke migration invoke active_record create db/migrate/20100529220831_user.rb error "add_fields_to_tags name:string label:string" [not found] I don't understand why I get this error... and I have 2 questions about: 1/ How can I do to customize the name of the generated file? Just like: 20100529220831_add_tag_field_to_users.rb. 2/ How can I pass in some args such as: $ rails generate acts_as_taggable_on User tag1 tag2 tag2 in order to customize the generating file such as tag1:string tag2:string tag3:string... Many thanks!

    Read the article

  • Rails 3.0.0.beta Install problem: can't find executable rails

    - by JZ
    I'm trying to install the rails 3.0.0.beta and I'm running into this issue: justins-mac-: justinz$ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] justins-mac-justinz$ rails -help /Library/Ruby/Site/1.8/rubygems.rb:384:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) from /usr/bin/rails:19 justins-mac-justinz$ rails -v /Library/Ruby/Site/1.8/rubygems.rb:384:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception) from /usr/bin/rails:19 justins-mac-justinz$ Any clues as to what is going on here?

    Read the article

  • Ruby on Rails equivalent for Maven Archetypes

    - by Drew
    Maven Archetypes are handy ways to get a project up and going in no time flat. Rails is kinda like an archetype in and of itself. However, I'm curious to know if there are any Rails equivalents for Maven Archetypes. For example, I want to create an Archetype with full authentication already built in via Authlogic. With Maven Archetypes I would need to build a project with it already ready to go, create my archetype and start working back parameterizing things that should be parameterized. Then anyone can make a Rails project with Authlogic set up by filling out a few questions during the archetype generate command and boom! Fully functional Rails app with Authlogic built in. Is there a Rails Equivalent? Are Generators expected to do this? Is this just not Rails-y?

    Read the article

  • How can I install Ruby on Rails 3 on OSX?

    - by Oluf Nielsen
    Hey i got an White Macbook and, has to go in 10 hours to a conference. And I'm having a lot of problems. First, I wanted to have Rails 3, so I used MacPorts to install Ruby 1.8.7. Tt worked well ;) So now I was thinking I should install Rails 3.. but no, no!.. it says.. $ sudo gem install rails --pre ERROR:   Error installing rails:                  activesupport requires Ruby version = 1.8.7. So what can I do? I have 1.8.7 !

    Read the article

  • Rails 3: What is the proper way to respond to REST-ful actions with JSON in rails?

    - by Damien Wilson
    Hello SO. I'm trying to make an API for my rails application using JSON responses to RESTful resource controllers. This is a new experience for me, so I'm looking for some guidance and pointers. To start things off: In a rails application, what is the "proper" way to respond with JSON to REST-ful controller methods? (create, update, destroy) Is there an idiomatic way to indicate success/failure through a JSON response? Additional information: I'm currently working with rails 3.0.beta2 I would like to avoid using a plugin or gem to do the grunt work, my goal is to gain a better understanding of how to make a rails 3 API. Links to places I could find more information on the topic would also be appreciated, some quick searching on google didn't do me much good.

    Read the article

  • Back again to use Rails 2.3.5 from Rails 3

    - by dreame4
    Hi, Recently, I had seen information about Rails 3.0 beta and I had wanted to trial it. So I used gem update and installed this version. But now, I need to go back to Rails 2.3.5. How could I do it? I was thinking about this two solutions: Uninstalling Rails 3. I read that somebody removed Rails 3 by using gem uninstall but he came across some problems then. Did anyone try to remove it in this way? Using different versions Rails at the same time. Is it possible at all? It will resolve all my problems but I could find nothing about this issue in google. Hope somebody could help me :) Greetings, dreame4

    Read the article

  • How to reflect in the database a new belongs_to and has_many relationship in Ruby on Rails

    - by Ken I.
    I am new to rails (usually a python guy) and have just been trying to build a simple task manager application for fun. I am using Devise for authentication and have a single Task object I am trying to relate to a user. I have added the following to the Task model: class Task < ActiveRecord::Base belongs_to :user end and I have added the following in my User model for Devise: class User < ActiveRecord::Base has_many :dreams <<normal Devise stuff>> end Whenever I added this information I then ran: rake db:migrate. It then gave me an error that the database field did not exist for user_id when I tried to do anything with it. I am sure it is something rather simple that I am missing. Thanks for the help.

    Read the article

  • Rails 3, changing a specific value in a row

    - by Elliot
    Hey Guys, This question seems ridiculously easy, but I seem to be stuck. Lets say we have a table "Books" Each Book, has a name, description, and a status. Lets say I want to create link in the show view, that when clicked, solely changes the status (to "read") for example. So far, I've tried adding a block in the controller, that says: def read @book = Book.find(params[:id]) @book.status = "Read" @book.update_attributes(params[:book]) respond_to do |format| format.html { redirect_to :back} format.xml { render :xml => @book } end end Then I've added a link to the view that is like: <%= link_to "Read", read_book_path(@book), :method = :put % This isn't working at all. I have added it to my routes, but it doesn't seem to matter. Any help would be great! Thanks! -Elliot EDIT: Forgot to add I'm getting a NoMethodError: undefined method `read_book_path'

    Read the article

  • can't update rails model

    - by Tristan
    Hi there, I'm rather new to rails. I have a controller that's attempting to update a model using the following code: @test = Product.find(1) @test.increment!(:price) It does successfully retrieve the Product from the database, but does not update the price attribute. Does anyone know why this might be the case, or how I could get more feedback on what the problem is? Thanks a bunch! Tristan edit: price is an integer with value 0. I get the same problem when I set the price with @test.price=50 and then @test.save .

    Read the article

  • How to create migration in subdirectory with Rails?

    - by Adrian Serafin
    Hi! I'm writing SaaS model application. My application database consist of two logic parts: application tables - such as user, roles... user defined tables (he can generate them from ui level) that can be different for each application instance All tables are created by rails migrations mechanism. I would like to put user defined tables in another directory: db/migrations - application tables db/migrations/custom - tables generated by user so i can do svn:ignore on db/migrations/custom, and when I do updates of my app on clients servers it would only update application tables migrations. Is there any way to achieve this in rails?

    Read the article

  • Trying to use a authlogic-connect as a plugin in place of gem - Server doesn't start

    - by Arkid
    I am trying to use Authlogic-connect as a plugin in Rails 3 in place of a gem. I have made an entry in the gemfile as gem "authlogic-connect", :require => "authlogic-connect", :path => "localgems" Now when I run the bundle install, it runs fine. When I try to start the server i get the error Could not find gem 'authlogic-connect (>= 0, runtime)' in source at localgems. Source does not contain any versions of 'authlogic-connect (>= 0, runtime)' Try running `bundle install`. I have placed the unzipped Gem renamed as authlogic-connect in the localgems folder. what is the problem? Here is what I get on using rails plugin install arkidmitra$ rails plugin install git://github.com/viatropos/authlogic-connect.git Usage: rails new APP_PATH [options] Options: [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files [--dev] # Setup the application with Gemfile pointing to your Rails checkout -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files -G, [--skip-git] # Skip Git ignores and keeps -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--edge] # Setup the application with Gemfile pointing to Rails repository Runtime options: -q, [--quiet] # Supress status output -s, [--skip] # Skip files that already exist -f, [--force] # Overwrite files that already exist -p, [--pretend] # Run but do not make any changes Rails options: -h, [--help] # Show this help message and quit -v, [--version] # Show Rails version number and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going.

    Read the article

  • Google Maps API with Rails 3.0

    - by JZ
    I'm wondering if anyone out there has worked with Google Maps API with Rails 3. I'm looking for launching ideas, gems, plugins etc. I played around with ym4r-gm plugin for several hours today, with not much luck. Have you played with this API on rails 3 yet? Thanks in advance!

    Read the article

  • how can i tell ruby to use the html string

    - by Matt
    i have this "<img src='#{picture.url(:tiny)}'>" which prints to this &lt;img src='/system/pictures/2/tiny/Womacdsf.jpg?1294942797'&gt;, &lt;img src='/system/pictures/3/tiny/Womacdsf_3017.jpg?1294942797'&gt;, &lt;img src='/system/pictures/4/tiny/Womacdsf_8012.jpg?1294942797'&gt;, … (8) as you can see this is doing the &lt; and &gt; instead of the < and how can i tell ruby this is not what i want

    Read the article

  • Creating thousands of records in Rails

    - by willCosgrove
    Let me set the stage: My application deals with gift cards. When we create cards they have to have a unique string that the user can use to redeem it with. So when someone orders our gift cards, like a retailer, we need to make a lot of new card objects and store them in the DB. With that in mind, I'm trying to see how quickly I can have my application generate 100,000 Cards. Database expert, I am not, so I need someone to explain this little phenomena: When I create 1000 Cards, it takes 5 seconds. When I create 100,000 cards it should take 500 seconds right? Now I know what you're wanting to see, the card creation method I'm using, because the first assumption would be that it's getting slower because it's checking the uniqueness of a bunch of cards, more as it goes along. But I can show you my rake task desc "Creates cards for a retailer" task :order_cards, [:number_of_cards, :value, :retailer_name] => :environment do |t, args| t = Time.now puts "Searching for retailer" @retailer = Retailer.find_by_name(args[:retailer_name]) puts "Retailer found" puts "Generating codes" value = args[:value].to_i number_of_cards = args[:number_of_cards].to_i codes = [] top_off_codes(codes, number_of_cards) while codes != codes.uniq codes.uniq! top_off_codes(codes, number_of_cards) end stored_codes = Card.all.collect do |c| c.code end while codes != (codes - stored_codes) codes -= stored_codes top_off_codes(codes, number_of_cards) end puts "Codes are unique and generated" puts "Creating bundle" @bundle = @retailer.bundles.create!(:value => value) puts "Bundle created" puts "Creating cards" @bundle.transaction do codes.each do |code| @bundle.cards.create!(:code => code) end end puts "Cards generated in #{Time.now - t}s" end def top_off_codes(codes, intended_number) (intended_number - codes.size).times do codes << ReadableRandom.get(CODE_LENGTH) end end I'm using a gem called readable_random for the unique code. So if you read through all of that code, you'll see that it does all of it's uniqueness testing before it ever starts creating cards. It also writes status updates to the screen while it's running, and it always sits for a while at creating. Meanwhile it flies through the uniqueness tests. So my question to the stackoverflow community is: Why is my database slowing down as I add more cards? Why is this not a linear function in regards to time per card? I'm sure the answer is simple and I'm just a moron who knows nothing about data storage. And if anyone has any suggestions, how would you optimize this method, and how fast do you think you could get it to create 100,000 cards? (When I plotted out my times on a graph and did a quick curve fit to get my line formula, I calculated how long it would take to create 100,000 cards with my current code and it says 5.5 hours. That maybe completely wrong, I'm not sure. But if it stays on the line I curve fitted, it would be right around there.)

    Read the article

  • What can I expect as the core stack for Rails 3.0 and what will I need to include now as a plugin

    - by DJTripleThreat
    So Rails and Merb are sort of merging in Rails 3.0? Thats how its been described to me anyway. This means that a lot of what made Rails, Rails will now be moved to plug-ins so that it can be more lightweight. HOwever, what are those plug-ins going to be and as a new Rails developer, what are THE must have - and also more mature - plug-ins that a Rails developer should install? Some good examples I can think of might be will_paginate, ruby_prof or sqlite3-ruby.

    Read the article

  • MongoMapper won't let me create an object

    - by Jade
    I'm just learning MongoDB and MongoMapper. This is on Rails 3. I created a blog in app/models/blog.rb: class Blog include MongoMapper::Document key :title, String, :required => true key :body, Text timestamps! end I go into the Rails console: rails c Loading development environment (Rails 3.0.0.beta) ruby-1.9.1-p378 > **b = Blog.new** NoMethodError: undefined method `from_mongo' for Text:Module from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:323:in `get' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:269:in `read_key' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:224:in `[]' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:7:in `block in inspect' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:6:in `collect' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:6:in `inspect' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:47:in `start' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:8:in `start' from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands.rb:34:in `<top (required)>' from /Users/jade/code/farmerjade/script/rails:10:in `require' from /Users/jade/code/farmerjade/script/rails:10:in `<main>' Am I overlooking something really dumb, or is this something in my setup? I'm using the mongo_mapper version you get by adding it to your Gemfile, so I'm wondering if it might be that. I'd appreciate any suggestions!

    Read the article

  • Rails 3 on dreamhost?

    - by p33t3r
    I'd like to deploy a small Rails 3 app on dreamhost (just testing purposes, nothing serious) and I am wondering if anyone did it already... please chose one of I did it and it's super easy, here's how: ... Though I didn't try it, it should be easy, here's how: ... It's quite complicated, but this should get you started: .... NO WAI!!!1!one!1 Set it up on slicehost or another non-shared hosting or you'll die a painful death trying to force it on DH Thoughts?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >