Search Results

Search found 9835 results on 394 pages for 'ruby on rails3'.

Page 12/394 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Ruby workflow in Windows

    - by Rig
    I've done some searching and quite haven't come across the answer I am looking for. I do not think this is a duplicate of this question. I believe Windows could be a suitable development environment based on the mix of answers in that question. I have been developing in Ruby (mostly Rails but not entirely) for about a year now for personal projects on a Macbook Pro however that machine has faced an untimely death and has been replaced with a nice Windows 7 machine. Ruby development felt almost natural on the Mac after doing some research and setting up the typical stack. My environment then included the standard (Linux like) stuff built into OSX, Text Wrangler, Git, RVM, et al. Not too much of a deviation from what the 'devotees' tend to assume. Now I am setting up my new Windows box for continuing that development. What would my development environment look like? Should I just cave and run Linux in a VM? Ideally I would develop in Windows native. I am aware of the Windows Ruby installer. It seems decent but its not exactly as nice as RVM in the osx/linux world. Mercurial/Git are available so I would assume they play into the stack. Does one develop entirely in Windows? Does one run a webserver in a Linux VM and use it as a test bed while developing in Windows? Do it all in a VM? What does the standard Windows Ruby developer environment look like and what is the workflow? What would a typical step through be for adding a new feature to an ongoing project and what would the technology stack look like?

    Read the article

  • Using JSON input in Ruby method on Rails

    - by Zachary
    I am using jQuery to make an AJAX call to a ruby method in my controller. The javascript looks something like this: var latLongJSON = { "address": [ {"lat" : 50, "long" : 50} ] }; var returnedAddresses; $.ajax({ type: "GET", data: latLongJSON, url: "map/getaddresses", success: function(data) { returnedAddresses = JSON.parse(data); } }); Then in my 'getaddresses' method, my parameter coming through looks like: Parameters: {"address"=>"[object Object]"} I'm not sure what to do with this. I'm fairly new to Ruby, and I'm not sure if I need to convert this to something else, or what. Ideally I want to be able to pass in multiple sets of lat/long in the 'address' array, then be able to iterate over those in my Ruby code.

    Read the article

  • Generating Google Maps markers using Ruby

    - by ischnura
    I would like to do a very simple task: add some markers in a Google Map using a list of addresses from an array. I have been thinking about generating the Google Maps JavaScript API code using ruby (printf) but this does not seem like a very clean and beautiful solution... I have read about YM4R for Ruby on Rails... my project is pretty simple and I have never worked with Ruby on Rails... I have also never used JQuerry... but I am very willing to learn to use this tools :) What do you think will be the best approach to generating the markers?

    Read the article

  • Rails: simple bundler question with ruby-openid

    - by Joern Akkermann
    Hi! I just installed the ruby-openid gem and then bundled it by entering gem 'ruby-openid', :require => 'openid' in the gemfile. Then I started bundle install and bundle lock. Everything worked fine so far. But how can I now access the classes of ruby-openid. OpenID::method won't work for me. It raises a not found error. What have I forgot or done wrong? I'm absolutely new to bundler and the internet full of solutions for various versions, but I need one solution that's surely working. I'm thankful for any help!

    Read the article

  • Most useful Rails plugins, Ruby libraries and Ruby gems?

    - by Srinivas Iyer
    I have seen many sites which provide the whole list of Rails plugins, Ruby libraries and Ruby gems, but we hardly use few of them and some may not suit our requirement and we spend a whole lot of time searching for useful plugins which suits our requirement. I have created this poll, people can post useful libraries, gems and plugins which they have come across. It would be great help for newbies like me and to the entire Ruby on Rails community. Note: to keep this poll as useful as possible, please remember: Post only one library, gem, or plugin per answer Mention the name of the library, gem, or plugin which you find it useful. URL of the location of the resource We don't want duplicate answers, so before posting check if the library has been mentioned already. Thanks

    Read the article

  • Could not load ruby textmate?

    - by mchenja
    I have a MacBook Pro, running Mavericks, but I'm not too acquainted with its inner workings. I'm just a humble CS student. After install Ruby 1.9.3 and Rails 4.0.0, I get this annoying message every time I open a new terminal window: Unknown ruby interpreter version (do not know how to handle): textmate. Could not load ruby textmate. The message is in bright red, so it worries me. What can I do to fix it/get rid of it? Thanks! EDIT: As it turns out, the message stopped showing, but I can't recall what I did to make it stop. In any case - thanks for reading!

    Read the article

  • link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?

    - by z3cko
    i am wondering if the basic link_to syntax is completely broken in current rails3 master or if i am doing some wrong syntax here. = link_to "name", nil, :onlick => "alert('Hello world!');" should actually produce an alert on click. very simple. does not work on my rails3 project! (also no error output!) any ideas? for the general link_to syntax i could not find an example where i could combine a link_to_remote with a confirmation, remote and html class (see my try below) = link_to "delete", {:action => "destroy", :remote => true, :method => :delete, :confirm => "#{a.title} wirklich L&ouml;schen?" }, :class => "trash" even the rails3 api does not help me here: http://rails3api.s3.amazonaws.com/index.html help!

    Read the article

  • What does the * symbol do near a function argument and how to use that in others scenarios?

    - by user502052
    I am using Ruby on Rails 3 and I would like to know what means the presence of a *simbol near a function argument and to understand its usages in others scenarios. Example scenario (this method was from the Ruby on Rails 3 framework: def find(*args) return to_a.find { |*block_args| yield(*block_args) } if block_given? options = args.extract_options! if options.present? apply_finder_options(options).find(*args) else case args.first when :first, :last, :all send(args.first) else find_with_ids(*args) end end end

    Read the article

  • Bundler isn't loading gems

    - by Garrett
    I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I defined my Gemfile like so: clear_sources source "http://gemcutter.org" source "http://gems.github.com" bundle_path "vendor/bundler_gems" ## Bundle edge rails: git "git://github.com/rails/arel.git" git "git://github.com/rails/rack.git" gem "rails", :git => "git://github.com/rails/rails.git" ## Bundle gem "mongo_mapper", :git => "git://github.com/jnunemaker/mongomapper.git" gem "bluecloth", ">= 2.0.0" Then I run gem bundle, it bundles it all up like expected. Inside the environment.rb file that is included within boot.rb it looks like this: # DO NOT MODIFY THIS FILE module Bundler file = File.expand_path(__FILE__) dir = File.dirname(file) ENV["PATH"] = "#{dir}/../../../../bin:#{ENV["PATH"]}" ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}" $LOAD_PATH.unshift File.expand_path("#{dir}/gems/builder-2.1.2/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/builder-2.1.2/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/text-hyphen-1.0.0/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/text-hyphen-1.0.0/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/i18n-0.3.3/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/i18n-0.3.3/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/arel/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/arel/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activemodel/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activemodel/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/jnunemaker-validatable-1.8.1/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/jnunemaker-validatable-1.8.1/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/abstract-1.0.0/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/abstract-1.0.0/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/erubis-2.6.5/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/erubis-2.6.5/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mime-types-1.16/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mime-types-1.16/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mail-2.1.2/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mail-2.1.2/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/railties/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/railties/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/memcache-client-1.7.7/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/memcache-client-1.7.7/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rack/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rack/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.3/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.3/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-mount-0.4.5/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-mount-0.4.5/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/actionpack/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/actionpack/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/bluecloth-2.0.7/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/bluecloth-2.0.7/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/bluecloth-2.0.7/ext") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activerecord/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activerecord/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/text-format-1.0.0/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/text-format-1.0.0/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/actionmailer/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/actionmailer/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/tzinfo-0.3.16/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/tzinfo-0.3.16/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activesupport/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activesupport/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activeresource/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/activeresource/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/rails/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mongo-0.18.2/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/gems/mongo-0.18.2/lib") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/mongomapper/bin") $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/mongomapper/lib") @gemfile = "#{dir}/../../../../Gemfile" require "rubygems" unless respond_to?(:gem) # 1.9 already has RubyGems loaded @bundled_specs = {} @bundled_specs["builder"] = eval(File.read("#{dir}/specifications/builder-2.1.2.gemspec")) @bundled_specs["builder"].loaded_from = "#{dir}/specifications/builder-2.1.2.gemspec" @bundled_specs["text-hyphen"] = eval(File.read("#{dir}/specifications/text-hyphen-1.0.0.gemspec")) @bundled_specs["text-hyphen"].loaded_from = "#{dir}/specifications/text-hyphen-1.0.0.gemspec" @bundled_specs["i18n"] = eval(File.read("#{dir}/specifications/i18n-0.3.3.gemspec")) @bundled_specs["i18n"].loaded_from = "#{dir}/specifications/i18n-0.3.3.gemspec" @bundled_specs["arel"] = eval(File.read("#{dir}/specifications/arel-0.2.pre.gemspec")) @bundled_specs["arel"].loaded_from = "#{dir}/specifications/arel-0.2.pre.gemspec" @bundled_specs["activemodel"] = eval(File.read("#{dir}/specifications/activemodel-3.0.pre.gemspec")) @bundled_specs["activemodel"].loaded_from = "#{dir}/specifications/activemodel-3.0.pre.gemspec" @bundled_specs["jnunemaker-validatable"] = eval(File.read("#{dir}/specifications/jnunemaker-validatable-1.8.1.gemspec")) @bundled_specs["jnunemaker-validatable"].loaded_from = "#{dir}/specifications/jnunemaker-validatable-1.8.1.gemspec" @bundled_specs["abstract"] = eval(File.read("#{dir}/specifications/abstract-1.0.0.gemspec")) @bundled_specs["abstract"].loaded_from = "#{dir}/specifications/abstract-1.0.0.gemspec" @bundled_specs["erubis"] = eval(File.read("#{dir}/specifications/erubis-2.6.5.gemspec")) @bundled_specs["erubis"].loaded_from = "#{dir}/specifications/erubis-2.6.5.gemspec" @bundled_specs["mime-types"] = eval(File.read("#{dir}/specifications/mime-types-1.16.gemspec")) @bundled_specs["mime-types"].loaded_from = "#{dir}/specifications/mime-types-1.16.gemspec" @bundled_specs["mail"] = eval(File.read("#{dir}/specifications/mail-2.1.2.gemspec")) @bundled_specs["mail"].loaded_from = "#{dir}/specifications/mail-2.1.2.gemspec" @bundled_specs["rake"] = eval(File.read("#{dir}/specifications/rake-0.8.7.gemspec")) @bundled_specs["rake"].loaded_from = "#{dir}/specifications/rake-0.8.7.gemspec" @bundled_specs["railties"] = eval(File.read("#{dir}/specifications/railties-3.0.pre.gemspec")) @bundled_specs["railties"].loaded_from = "#{dir}/specifications/railties-3.0.pre.gemspec" @bundled_specs["memcache-client"] = eval(File.read("#{dir}/specifications/memcache-client-1.7.7.gemspec")) @bundled_specs["memcache-client"].loaded_from = "#{dir}/specifications/memcache-client-1.7.7.gemspec" @bundled_specs["rack"] = eval(File.read("#{dir}/specifications/rack-1.1.0.gemspec")) @bundled_specs["rack"].loaded_from = "#{dir}/specifications/rack-1.1.0.gemspec" @bundled_specs["rack-test"] = eval(File.read("#{dir}/specifications/rack-test-0.5.3.gemspec")) @bundled_specs["rack-test"].loaded_from = "#{dir}/specifications/rack-test-0.5.3.gemspec" @bundled_specs["rack-mount"] = eval(File.read("#{dir}/specifications/rack-mount-0.4.5.gemspec")) @bundled_specs["rack-mount"].loaded_from = "#{dir}/specifications/rack-mount-0.4.5.gemspec" @bundled_specs["actionpack"] = eval(File.read("#{dir}/specifications/actionpack-3.0.pre.gemspec")) @bundled_specs["actionpack"].loaded_from = "#{dir}/specifications/actionpack-3.0.pre.gemspec" @bundled_specs["bluecloth"] = eval(File.read("#{dir}/specifications/bluecloth-2.0.7.gemspec")) @bundled_specs["bluecloth"].loaded_from = "#{dir}/specifications/bluecloth-2.0.7.gemspec" @bundled_specs["activerecord"] = eval(File.read("#{dir}/specifications/activerecord-3.0.pre.gemspec")) @bundled_specs["activerecord"].loaded_from = "#{dir}/specifications/activerecord-3.0.pre.gemspec" @bundled_specs["text-format"] = eval(File.read("#{dir}/specifications/text-format-1.0.0.gemspec")) @bundled_specs["text-format"].loaded_from = "#{dir}/specifications/text-format-1.0.0.gemspec" @bundled_specs["actionmailer"] = eval(File.read("#{dir}/specifications/actionmailer-3.0.pre.gemspec")) @bundled_specs["actionmailer"].loaded_from = "#{dir}/specifications/actionmailer-3.0.pre.gemspec" @bundled_specs["tzinfo"] = eval(File.read("#{dir}/specifications/tzinfo-0.3.16.gemspec")) @bundled_specs["tzinfo"].loaded_from = "#{dir}/specifications/tzinfo-0.3.16.gemspec" @bundled_specs["activesupport"] = eval(File.read("#{dir}/specifications/activesupport-3.0.pre.gemspec")) @bundled_specs["activesupport"].loaded_from = "#{dir}/specifications/activesupport-3.0.pre.gemspec" @bundled_specs["activeresource"] = eval(File.read("#{dir}/specifications/activeresource-3.0.pre.gemspec")) @bundled_specs["activeresource"].loaded_from = "#{dir}/specifications/activeresource-3.0.pre.gemspec" @bundled_specs["rails"] = eval(File.read("#{dir}/specifications/rails-3.0.pre.gemspec")) @bundled_specs["rails"].loaded_from = "#{dir}/specifications/rails-3.0.pre.gemspec" @bundled_specs["mongo"] = eval(File.read("#{dir}/specifications/mongo-0.18.2.gemspec")) @bundled_specs["mongo"].loaded_from = "#{dir}/specifications/mongo-0.18.2.gemspec" @bundled_specs["mongo_mapper"] = eval(File.read("#{dir}/specifications/mongo_mapper-0.6.10.gemspec")) @bundled_specs["mongo_mapper"].loaded_from = "#{dir}/specifications/mongo_mapper-0.6.10.gemspec" def self.add_specs_to_loaded_specs Gem.loaded_specs.merge! @bundled_specs end def self.add_specs_to_index @bundled_specs.each do |name, spec| Gem.source_index.add_spec spec end end add_specs_to_loaded_specs add_specs_to_index def self.require_env(env = nil) context = Class.new do def initialize(env) @env = env && env.to_s ; end def method_missing(*) ; yield if block_given? ; end def only(*env) old, @only = @only, _combine_only(env.flatten) yield @only = old end def except(*env) old, @except = @except, _combine_except(env.flatten) yield @except = old end def gem(name, *args) opt = args.last.is_a?(Hash) ? args.pop : {} only = _combine_only(opt[:only] || opt["only"]) except = _combine_except(opt[:except] || opt["except"]) files = opt[:require_as] || opt["require_as"] || name files = [files] unless files.respond_to?(:each) return unless !only || only.any? {|e| e == @env } return if except && except.any? {|e| e == @env } if files = opt[:require_as] || opt["require_as"] files = Array(files) files.each { |f| require f } else begin require name rescue LoadError # Do nothing end end yield if block_given? true end private def _combine_only(only) return @only unless only only = [only].flatten.compact.uniq.map { |o| o.to_s } only &= @only if @only only end def _combine_except(except) return @except unless except except = [except].flatten.compact.uniq.map { |o| o.to_s } except |= @except if @except except end end context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1) end end module Gem @loaded_stacks = Hash.new { |h,k| h[k] = [] } def source_index.refresh! super Bundler.add_specs_to_index end end But when I try to access any of my gems, e.g. MongoMapper, Paperclip, Haml, etc. I get: NameError: uninitialized constant MongoMapper The same goes for any other gem. Does Bundler not include gems like the old Rails 2.0 did? Or is something messed up with my system? Any help would be appreciated, thank you!

    Read the article

  • Rails 3 and RJS

    - by Denis
    Hi, I use the rails 3.0.0.beta Is there any new syntax to write RJS, here is an example def remote_create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save # add @photo's thumbnail to last import tag format.js { render :update do |page| page.insert_html :bottom, 'polaroids' , :partial => 'polaroid', :locals => {:photo => @photo} end } else #... end end end

    Read the article

  • How can I get ambethia's captcha plugin to work in rails 3?

    - by James
    I have installed ambethia's captcha plugin as a plugin in my rails 3 app. When I put the <%= recaptcha_tags %> in my view, it puts this on the page: <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=my_key&error=expression"></script> <noscript> <iframe src="http://api.recaptcha.net/noscript?k=my_other_key" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript> Is there a way that I can make this work in rails 3? I'd appreciate any help.

    Read the article

  • Problem in Rail Casts Episode 190

    - by Gautam
    Hello, This is the code I have written require 'rubygems' require 'nokogiri' require 'open-uri' url = "http://timesofindia.indiatimes.com/rssfeeds/-2128838597.cms" doc = Nokogiri::HTML(open(url)) puts doc.at_css("title").text and I am getting this output. I have installed Nokogiri. I use Windows 7 C:\Ruby>ruby hello.rb C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogiri.rb:1:in `require': 127: The specified procedure could not be found. - Init_nokogiri (LoadError) C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/1.9/nokogiri.so from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogiri.rb:1:in `<top (required)>' from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri.rb:13:in `require' from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri.rb:13:in `<top (required)>' from hello.rb:2:in `require' from hello.rb:2:in `<main>'

    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, 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

  • 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

  • How do I combine two methods into one json formatted variable?

    - by JZ
    I'm storing JSON formatted data into a var adds with the following methods: var adds = <%= raw @add.to_a.to_json %>; var adds = <%= raw @add.nearbys(1).to_json %>; The first line of code stores the location of an individual in JSON format, the second line of code searches for that person's neighbors, within a 1 mile range. How do I combine both of these lines of code and store the data in JSON format in the var adds variable? If you are interested in source, its here. The location is layout/adds.html.erb

    Read the article

  • Creating a nested model form

    - by Elliot
    Hey Guys, I'm trying to build a multi model form - but one of the issues, is I need to link the models within the form. For example, lets say the form I have has the following models: Users, Profiles When creating a new user, I'd like to create a new profile simultaneously, and then link the two. The issue is, if neither have been created yet, they don't have ID's yet - so how can I assign linking values? Thanks! -Elliot

    Read the article

  • [Rails 3] Creating helper tag with UJS

    - by Theo B
    Firstly, sorry for my english. I´m brazilian guy that is improving yet. I want create a helper tag called "collection_cascading_select". That helper is similar to "collection_select", but he has one more argument called "source". The "source" is the other collection in the view. Ever that other option is select in the "source", a javascript function needs run to gets his value. Then populate the "collection_cascading_select" collection agreed of that value. That gets confusing ?!? Sorry... But help me! I'm one week in this problem and my brazilian brothers don´t are help me. THANKS!

    Read the article

  • Does acts-as-taggable-on work on heroku?

    - by Martin
    Hello, I have a question: does the acts-as-taggable-on gem work on Heroku? I'been trying but it doesn't seem to work. In my development machine works okay. I'm wondering if it's maybe because Heroku uses PostgreSQL and my local env SQLite and for some reason postgresql is not supported by the special tagging "magic"? I couldn't find any related info to this, so I would like to know other experiences with this. I guess is pretty rare since both the gem and heroku are very popular. ActionView::Template::Error (undefined method `interests' for "#<About:0x2b35d6125728>":About): <% unless @user.about.interests.empty? %> <p><strong>interests and passions</strong><br /> <% @user.about.interests.each do |tag| %> <%= tag %>, <% end -%></p><% end %> In my about.rb model i have acts_as_taggable_on :interests, :music, :movies, :books, :tvs Thank you in advance!

    Read the article

  • How do I do a join in ActiveRecord after records have been returned?

    - by Russ Bradberry
    I am using ActiveRecord in Rails 3 to pull data from two different tables in two different databases. These databases can not join on each other, but I have the need to do a simple join after-the-fact. I would like to preserve the relation so that I can chain it down the line. here is a simplified version of what I am doing browsers = Browser.all # <-- this is fairly small and can reside in memory events = Event.where(:row_date=>Date.today).select(:name, :browser_id) So as you can see, I want to join browsers in on the events relation, where browser_id should equal browsers.name. events is a relation and I can still add clauses to it down the line, so I dont want to run the query on the db just yet. How would I accomplish this?

    Read the article

  • Linking two models in a multi-model form

    - by Elliot
    Hey Guys, I have a nested multimodel form right now, using Users and Profiles. Users has_one profile, and Profile belongs_to Users. When the form is submitted, a new user is created, and a new profile is created, but they are not linked (this is the first obvious issue). The user's model has a profile_id row, and the profile's model has a user_id row. Here is the code for the form: <%= form_for(@user, :url => teams_path) do |f| %> <p><%= f.label :email %><br /> <%= f.text_field :email %></p> <p><%= f.label :password %><br /> <%= f.password_field :password %></p> <p><%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation %></p> <%= f.hidden_field :role_id, :value => @role.id %></p> <%= f.hidden_field :company_id, :value => current_user.company_id %></p> <%= fields_for @user.profile do |profile_fields| %> <div class="field"> <%= profile_fields.label :first_name %><br /> <%= profile_fields.text_field :first_name %> </div> <div class="field"> <%= profile_fields.label :last_name %><br /> <%= profile_fields.text_field :last_name %> </div> <% end %> <p><%= f.submit "Sign up" %></p> <% end %> A second issue, is even though the username, and password are successfully created through the form for the user model, the hidden fields (role_id & company_id - which are also links to other models) are not created (even though they are part of the model) - the values are successfully shown in the HTML for those fields however. Any help would be great!

    Read the article

  • Local install of sqlite3-ruby

    - by Skully
    On my current system i dont have root-access and i want to install sqlite3-ruby. I can compile it and i know how to set custom install-folder, but how does my ruby-installation can recognize/find that installed gem for usage? I tried prefix of my custom RUBYLIB-Folder but that didnt work either. Any suggestions? Thanks skully

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >