Stack Overflow

A language-independent collaboratively edited question and answer site for programmers.

  • on Rails - No route matches [POST] "/setor/update"

    stackoverflow.com 14 May '17, 12am

    i'm new to ruby on rails and I keep getting this error when trying to update an object. here's my controller: class SetorController < ApplicationController def index @setor = Setor.all end def new end def show @setor = Setor.find(params[:id]) end def create @setor = Setor.new(setor_pa...

  • In mongodb,How to use ruby on rails "migration" tools

    stackoverflow.com 03 May '17, 7pm

    In ruby on rails normally use SQLite as a database.so a special property of rails called migration are work.but when we use "mongodb" as a database in rails.I see there have no migrate folder in the db directory. Is there any way to use this migration property in rails when use mongodb.

  • AWS Elastic beanstalk Ruby App not loading Production ENV

    stackoverflow.com 01 May '17, 4pm

    My Ruby on Rails app on AWS Elastic beanstalk is for loading the staging environment, even though it has been configured as production. BUNDLE_PATH: vendor/bundle RAILS_ENV: production RAILS_SKIP_ASSET_COMPILATION: false RAILS_SKIP_MIGRATIONS: false BUNDLE_WITHOUT: test:development RA...

  • java - Learning Web Development : Django vs Node vs Rails vs Others

    stackoverflow.com 27 Apr '17, 7pm

    The asynchronous programming approach in Node.js is conceptually more difficult. While you can take a similar approach in Django or Rails, it's not common to do so. Node.js is really, really fast out of the box. But part of the reason for that is that it doesn't include very much OOB....

  • Common Ruby Idioms

    stackoverflow.com 22 Apr '17, 12am

    The magic if clause that lets the same file serve as a library or a script: if __FILE__ == $0 # this library may be run as a standalone script end Packing and unpacking arrays: # put the first two words in a and b and the rest in arr a,b,*arr = *%w{a dog was following me, but then he ...

  • Writing beautiful Ruby

    idiom for "foo.nil? ? nil : foo.to_i"?

    stackoverflow.com 23 Apr '17, 2am

    def bar(foo) foo.to_i unless foo.nil? end But you don't really gain anything, IMO, except eliminating the ? ? . It's a character shorter, potentially more readable if you know Ruby. Don't know as it qualifies as "more concise" than the ternary. (I say "potentially" because it might be...

  • on rails - Order query by number of times one model has another

    stackoverflow.com 25 Mar '17, 6am

    I have the following structure: User model: id, .. Event model: id, .. UserMapEvent model: user_id, event_id For example the UserMapEvent table might have the following records: User_id - Event_id 1 - 1 1 - 2 3 - 1 4 - 1 I'm using this structure to save when a user likes an event. Now...

  • How to insert post data in mongodb using ruby on rails

    stackoverflow.com 06 Mar '17, 10am

    I am trying to insert article post data in mongodb collection but I got below error. Mongoid::Errors::NoParent at /articles message: Cannot persist embedded document Article without a parent document. summary: If the document is embedded, in order to be persisted it must always have a...