Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 121/378 | < Previous Page | 117 118 119 120 121 122 123 124 125 126 127 128  | Next Page >

  • Basic Facts About Ruby on Rails Programming Language

    The saying "Feels lighter, more agile, and easier to understand" has become the definition for ruby on rails. Many people still don't know that ror is otherwise called as ruby on rails. Let's learn more about the basic facts of ruby on rails, the lightening fast programming language today.

    Read the article

  • what receives an ajax call?

    - by jbcolmenares
    I'm making a site which should (a) take information from the user in the form of files and forms, (b) take that data to the server to be run on a C application, and (c) take the result back and show it to the user. I was told to look for AJAX for the communication with the server. BTW, I'm using rails. I'm trying to understand how AJAX works. From what I understand so far, with rails is pretty easy to make the call. What I can't figure out is, what waits for that call? what process the call? If I understand correctly, with rails I could make a function in ruby and make it so it's called through AJAX, which means -or so I understand- that it gets executed on the server. If I were using PHP, would I need to make an http server to wait for the AJAX calls? I just don't find information about what waits for the call, and that information is processed. Any links, comments or books are welcome!

    Read the article

  • Basics of Website development [closed]

    - by user975234
    I have read this post: What should every programmer know about web development? but I have some more questions... I will be developing a content related website very soon and I am confused about some technology stuff. I am thinking about developing the site using ruby on rails. So when I'll be buying hosting, do I need to ask for something special? Like for example, we need to specify what kind of hosting we need, windows or linux. So for ruby on rails do I need some extra facilities from the hosting provider? Is ruby on rails a good choice for a large content related website? This may be a bit stupid but how do I choose my backend, scripting languages etc? Thing is I am really new to website development. And the flow of making websites is not clear. Any links will be helpful. EDIT: I know this question has been voted as non constructive. But if any one still has some precise knowledge about how the flow of website development goes, please comment your views.. That will be helpful!

    Read the article

  • Perl script rendered in browser as code through symlink - fine when accessed directly

    - by John Dittmar
    I have a Rails 4 app that has some views that post to Perl cgi scripts. The perl scripts are accessed via a symbolic link to a folder called "cgi-bin". When I navigate to a perl script through the symbolic link they are rendered as text instead of executed (ie: localhost:3000/cgi-bin/test.cgi), however when I access them directly they execute without issue (ie. localhost/path/to/cgi-bin/test.cgi). I am using apache2 on os x. In the directory localhost/path/to/ I have an .htaccess file that contains the following: # General Apache options AddHandler fastcgi-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI I have the exact same lines in the .htaccess file that I have in localhost:3000/ I have also uncommented the AllowOverride all in httpd.conf. The are no errors in apache's error log. When I access the direct link to test.cgi a new line is appended to apache's access log, when I access the script through the symbolic link (and it is rendered as text), there is no line appended to the access log. Any idea why this error occurs? This setup worked fine in a previous version of rails of OS X, but recently I upgraded to Mavericks and figured I should update the Rails application to v4.0 as well.

    Read the article

  • Configure Cucumber with SentientUser

    - by Corith Malin
    I have an application using the SentientUser gem to provide the current user to my models. On top of that I'm using default scoping to ensure that a user can only ever access data that they own. So a typical model for me looks something like this: class Location < ActiveRecord::Base validates_presence_of :name, :time_zone, :address belongs_to :account belongs_to :address accepts_nested_attributes_for :address default_scope :conditions => { :account_id => User.current.account } end When I run rake cucumber I get an error on the default_scope line about account being nil. My guess is that when the cucumber rake task is run it doesn't have access to the correct application controller to inject the current_user method and thus SentientUser can't get the current user? The error I get is: rake cucumber (in /Users/corithmalin/Documents/Code/Ruby/flavorpulse) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I "/Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/lib:lib" "/Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/cucumber" --profile default Using the default profile... undefined method `account' for nil:NilClass (NoMethodError) /Users/corithmalin/Documents/Code/Ruby/flavorpulse/vendor/rails/activesupport/lib/active_support/whiny_nil.rb:52:in `method_missing' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/app/models/location.rb:9 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/vendor/rails/activesupport/lib/active_support/dependencies.rb:265:in `require_or_load' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/vendor/rails/activesupport/lib/active_support/dependencies.rb:224:in `depend_on' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/vendor/rails/activesupport/lib/active_support/dependencies.rb:136:in `require_dependency' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:414:in `load_application_classes' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:413:in `each' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:413:in `load_application_classes' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:411:in `each' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:411:in `load_application_classes' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:197:in `process' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:113:in `send' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/../vendor/rails/railties/lib/initializer.rb:113:in `run' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/config/environment.rb:9 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /Users/corithmalin/Documents/Code/Ruby/flavorpulse/features/support/env.rb:8 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/rb_support/rb_language.rb:124:in `load_code_file' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:85:in `load_code_file' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:77:in `load_code_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in `each' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in `load_code_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:48:in `execute!' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:20:in `execute' /Library/Ruby/Gems/1.8/gems/cucumber-0.6.3/bin/cucumber:8 rake aborted! Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...] (See full trace by running task with --trace)

    Read the article

  • What is the best error monitoring tool for Ruby on Rails applications?

    - by marcgg
    I'm looking for something to track the errors being raised across our multiple rails applications on our multiple servers. Ideally: the application failings sends an email to [email protected] and the email is processed in another application. This application will then show us some stats and give us some kinds of auditing tools. A service like Hoptoad might do the trick, but I'm trying to see what's available these days. Ideally free or cheap, of course...

    Read the article

  • Ruby on Rails is complaining about a method that doesn't exist that is built into Active Record. Wha

    - by grg-n-sox
    This will probably just be a simple problem and I am just blind or an idiot but I could use some help. So I am going over some basic guides in Rails, reviewing the basics and such for an upcoming exam. One of the guides included was the sort-of-standard getting started guide over at guide.rubyonrails.org. Here is the link if you need it. Also all my code is for my app is from there, so I have no problem releasing any of my code since it should be the same as shown there. I didn't do a copy paste, but I basically was typing with Vim in one half of my screen and the web page in the other half, typing what I see. http://guides.rubyonrails.org/getting_started.html So like I said, I am going along the guide when I noticed past a certain point in the tutorial, I was always getting an error on the site. To find the section of code, just hit Ctrl+f on the page (or whatever you have search/find set to) and enter "accepts_". This should immediately direct you to this chunk of code. class Post < ActiveRecord::Base validates_presence_of :name, :title validates_length_of :title, :minimum => 5 has_many :comments has_many :tags accepts_nested_attributes_for :tags, :allow_destroy => :true , :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } end So I tried putting this in my code. It is in ~/Rails/blog/app/models/post.rb in case you are wondering. However, even after all the other code I put in past that in the guide, hoping I was just missing some line of code that would come up later in the guide. But nothing, same error every time. This is what I get. NoMethodError in PostsController#index undefined method `accepts_nested_attributes_for' for #<Class:0xb7109f98> /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in `method_missing' app/models/post.rb:7 app/controllers/posts_controller.rb:9:in `index' Request Parameters: None Response Headers: {"Content-Type"=>"", "cookie"=>[], "Cache-Control"=>"no-cache"} Now, I copied the above code from the guide. The two code sections I edited mentioned in the error message I will paste as is below. class PostsController < ApplicationController # GET /posts # GET /posts.xml before_filter :find_post, :only => [:show, :edit, :update, :destroy] def index @posts = Post.find(:all) # <= the line 9 referred to in error message respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } end end class Post < ActiveRecord::Base validates_presence_of :name, :title validates_length_of :title, :minimum => 5 has_many :comments has_many :tags accepts_nested_attributes_for :tags, :allow_destroy => :true , # <= problem :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } end Also here is gem local gem list. I do note that they are a bit out of date, but the default Rails install any of the school machines (an environment likely for my exam) is basically 'gem install rails --version 2.2.2' and since they are windows machines, they come with all the normal windows ruby gems that comes with the ruby installer. However, I am running this off a Debian virtual machine of mine, but trying to set it up similarly and I figured the windows ruby gems wouldn't change anything in Rails. *** LOCAL GEMS *** actionmailer (2.2.2) actionpack (2.2.2) activerecord (2.2.2) activeresource (2.2.2) activesupport (2.2.2) gem_plugin (0.2.3) hpricot (0.8.2) linecache (0.43) log4r (1.1.7) ptools (1.1.9) rack (1.1.0) rails (2.2.2) rake (0.8.7) sqlite3-ruby (1.2.3) So any ideas on what the problem is? Thanks in advanced.

    Read the article

  • Why is apache/passenger unable to open the sqlite3 rails database file?

    - by sendos
    I'm running apache2/passenger2.0.3 (ubuntu 9.10 packages). I can start up Webrick in the rails folder and run the app perfectly as I do on my development box with script/server Why then does apache/passenger fail to open the database, throwing a 500 and putting the following in the log? Status: 500 Internal Server Error could not open database: unable to open database file /usr/lib/ruby/1.8/sqlite3/errors.rb:62:in `check'...

    Read the article

  • shopify_app syntax error

    - by Pete171
    Edit: Debugging has got me further. Question clarified. We have installed Ruby, RubyGems and Rails and have forked the shopify_app project. We have created a new rails applications and added three items to the Gemfile: execjs, therubyracer and shopify_app. Running rails s in order to start our rails application returns this trace: root@ubuntu:/usr/local/pete-shopify/cart# rails s Faraday: you may want to install system_timer for reliable timeouts /var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15:in `require': /var/lib /gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app/login_protection.rb:5: syntax error, unexpected ':', expecting kEND (SyntaxError) ...rce::UnauthorizedAccess, with: :close_session ^ from /var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15 from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `require' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require' from /var/lib/gems/1.8/gems/bundler-1.2.1/lib/bundler.rb:128:in `require' from /usr/local/pete-shopify/cart/config/application.rb:7 from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require' from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:53 from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap' from /var/lib/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:50 from script/rails:6:in `require' from script/rails:6 I haven't modified any files since forking from Github. Lines 1 - 6 of login_protection.rb are as follows: module ShopifyApp::LoginProtection extend ActiveSupport::Concern included do rescue from ActiveResource::UnauthorizedAccess, with: :close_session end I've looked into this and it seems that the error is caused by a new-style hash syntax between Ruby 1.8 and 1.9; key : value instead of key => value. Running ruby -v from the command line returns ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]. This would seem to be OK... but I did some debugging, and inside the file /var/lib/gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb (at the top) by putting this: puts RUBY_VERSION exit It printed 1.8.7. **Why are ruby -v and RUBY_VERSION giving me different results? And am I correct in assuming this is the cause of my problems? Note: To upgrade Ruby I installed the later version with apt-get and then switched to it by using update-alternatives --config ruby and selecting option 2 like this: root@ubuntu:/usr/local/pete-shopify/cart# update-alternatives --config ruby There are 2 choices for the alternative ruby (providing /usr/bin/ruby). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/ruby1.8 50 auto mode 1 /usr/bin/ruby1.8 50 manual mode * 2 /usr/bin/ruby1.9.1 10 manual mode Also note: We're PHP/Python developers so this is all new to us! Summary: 1 - Am I right in determining the cause of the syntax error? 2 - Why does RUBY_VERSION and ruby -v give me different results?

    Read the article

  • Ruby on Rails - where to write business logic while processing a request? (newbie)

    - by Genadinik
    I am learning Ruby on Rails. I made a simple link like this: <%= link_to "Alex Link", alexes_path(@alex) %> then I routed it in routes.rb like this: resources :alexes get "home/index" then I am a bit unclear, but I think it goes to this part of the controller: def index #@alexes = Alex.all respond_to do |format| format.html # index.html.erb format.json { render json: @alexes } end end Am I correct that it goes to this part of the controller? Then nothing much happens and it goes to the next page which is index.html.rb under views\alexes So what I am wondering is - if I needed to do some business logic, would I write that in the controller snippet? Where inside the snippet? An example would be nice to take a look. Also, I would like to connect to a MongoDb database. Would I also write that in the middle of the controller? Thanks!

    Read the article

  • Rails 3 NameError (cannot remove Object::Version) error

    - by Jeff D
    Can anyone point me at what might be causing this error? There is no ApplicationTrace, and it locks the server hard on my development machine. I think it has something to do with the way rails reloads your classes in development mode, and it appears to have something to do with a Version constant. I can't find a reference to this though. Can anyone point me in the direction of what would cause this? activesupport (3.0.3) lib/active_support/dependencies.rb:645:in `remove_const' activesupport (3.0.3) lib/active_support/dependencies.rb:645:in `remove_constant' activesupport (3.0.3) lib/active_support/dependencies.rb:645:in `instance_eval' activesupport (3.0.3) lib/active_support/dependencies.rb:645:in `remove_constant' activesupport (3.0.3) lib/active_support/dependencies.rb:521:in `remove_unloadable_constants!' activesupport (3.0.3) lib/active_support/dependencies.rb:521:in `each' activesupport (3.0.3) lib/active_support/dependencies.rb:521:in `remove_unloadable_constants!' activesupport (3.0.3) lib/active_support/dependencies.rb:317:in `clear' railties (3.0.3) lib/rails/application/bootstrap.rb:60:in `_callback_after_7' activesupport (3.0.3) lib/active_support/callbacks.rb:419:in `_run_call_callbacks' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in `call' rack (1.2.1) lib/rack/sendfile.rb:107:in `call' actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call' actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call' railties (3.0.3) lib/rails/rack/logger.rb:13:in `call' rack (1.2.1) lib/rack/runtime.rb:17:in `call' activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call' rack (1.2.1) lib/rack/lock.rb:11:in `call' rack (1.2.1) lib/rack/lock.rb:11:in `synchronize' rack (1.2.1) lib/rack/lock.rb:11:in `call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in `call' railties (3.0.3) lib/rails/application.rb:168:in `call' railties (3.0.3) lib/rails/application.rb:77:in `send' railties (3.0.3) lib/rails/application.rb:77:in `method_missing' railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call' rack (1.2.1) lib/rack/content_length.rb:13:in `call' rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:162:in `start' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:95:in `start' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:92:in `each' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:92:in `start' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:23:in `start' /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:82:in `start' rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run' rack (1.2.1) lib/rack/server.rb:213:in `start' railties (3.0.3) lib/rails/commands/server.rb:65:in `start' railties (3.0.3) lib/rails/commands.rb:30 railties (3.0.3) lib/rails/commands.rb:27:in `tap' railties (3.0.3) lib/rails/commands.rb:27 script/rails:6:in `require' script/rails:6

    Read the article

  • Ruby on Rails: How to sanitize a string for SQL when not using find?

    - by williamjones
    I'm trying to sanitize a string that involves user input without having to resort to manually crafting my own possibly buggy regex if possible, however, if that is the only way I would also appreciate if anyone can point me in the right direction to a regex that is unlikely to be missing anything. There are a number of methods in Rails that can allow you to enter in native SQL commands, how do people escape user input for those? The question I'm asking is a broad one, but in my particular case, I'm working with a column in my Postgres database that Rails does not natively understand as far as I know, the tsvector, which holds plain text search information. Rails is able to write and read from it as if it's a string, however, unlike a string, it doesn't seem to be automatically escaping it when I do things like vector= inside the model. For example, when I do model.name='::', where name is a string, it works fine. When I do model.vector='::' it errors out: ActiveRecord::StatementInvalid: PGError: ERROR: syntax error in tsvector: "::" "vectors" = E'::' WHERE "id" = 1 This seems to be a problem caused by lack of escaping of the semicolons, and I can manually set the vector='\:\:' fine. I also had the bright idea, maybe I can just call something like: ActiveRecord::Base.connection.execute "UPDATE medias SET vectors = ? WHERE id = 1", "::" However, this syntax doesn't work, because the raw SQL commands don't have access to find's method of escaping and inputting strings by using the ? mark. This strikes me as the same problem as calling connection.execute with any type of user input, as it all boils down to sanitizing the strings, but I can't seem to find any way to manually call Rails' SQL string sanitization methods. Can anyone provide any advice?

    Read the article

  • Ruby on Rails: How to sanitize a string for SQL when not using find and other built-in methods?

    - by williamjones
    I'm trying to sanitize a string that involves user input without having to resort to manually crafting my own possibly buggy regex if possible. There are a number of methods in Rails that can allow you to enter in native SQL commands, how do people escape user input for those? The question I'm asking is a broad one, but in my particular case, I'm working with a column in my Postgres database that Rails does not natively understand as far as I know, the tsvector, which holds plain text search information. Rails is able to write and read from it as if it's a string, however, unlike a string, it doesn't seem to be automatically escaping it when I do things like vector= inside the model. For example, when I do model.name='::', where name is a string, it works fine. When I do model.vector='::' it errors out: ActiveRecord::StatementInvalid: PGError: ERROR: syntax error in tsvector: "::" "vectors" = E'::' WHERE "id" = 1 This seems to be a problem caused by lack of escaping of the semicolons, and I can manually set the vector='\:\:' fine. I also had the bright idea, maybe I can just call something like: ActiveRecord::Base.connection.execute "UPDATE medias SET vectors = ? WHERE id = 1", "::" However, this syntax doesn't work, because the raw SQL commands don't have access to find's method of escaping and inputting strings by using the ? mark. This strikes me as the same problem as calling connection.execute with any type of user input, as it all boils down to sanitizing the strings, but I can't seem to find any way to manually call Rails' SQL string sanitization methods. Can anyone provide any advice?

    Read the article

  • Adding defaults and indexes to a script/generate command in a Rails Template?

    - by charliepark
    I'm trying to set up a Rails Template that would allow for comprehensive set-up of a specific Rails app. Using Pratik Naik's overview (http://m.onkey.org/2008/12/4/rails-templates), I was able to set up a couple of scaffolds and models, with a line that looks something like this ... generate("scaffold", "post", "title:string", "body:string") I'm now trying to add in Delayed Jobs, which normally has a migration file that looks like this: create_table :delayed_jobs, :force => true do |table| table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually. table.text :handler # YAML-encoded string of the object that will do work table.text :last_error # reason for last failure (See Note below) table.datetime :run_at # When to run. Could be Time.now for immediately, or sometime in the future. table.datetime :locked_at # Set when a client is working on this object table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) table.string :locked_by # Who is working on this object (if locked) table.timestamps end So, what I'm trying to do with the Rails template, is to add in that :default = 0 into the master template file. I know that the rest of the template's command should look like this: generate("migration", "createDelayedJobs", "priority:integer", "attempts:integer", "handler:text", "last_error:text", "run_at:datetime", "locked_at:datetime", "failed_at:datetime", "locked_by:string") Where would I put (or, rather, what is the syntax to add) the :default values in that? And if I wanted to add an index, what's the best way to do that?

    Read the article

  • Why does Ruby have Rails while Python has no central framework?

    - by yar
    This is a(n) historical question, not a comparison-between-languages question: This article from 2005 talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. Why, historically speaking, did this happen for Ruby but not for Python? (or did it happen, and that framework is Django?) Also, the hypothetical questions: would Python be more popular if it had one, good framework? Would Ruby be less popular if it had no central framework? [Please avoid discussions of whether Ruby or Python is better, which is just too open-ended to answer.] Edit: Though I thought this is obvious, I'm not saying that other frameworks do not exist for Ruby, but rather that the big one in terms of popularity is Rails. Also, I should mention that I'm not saying that frameworks for Python are not as good (or better than) Rails. Every framework has its pros and cons, but Rails seems to, as Ben Blank says in the one of the comments below, have surpassed Ruby in terms of popularity. There are no examples of that on the Python side. WHY? That's the question.

    Read the article

  • How can I abstract out the core functionality of several Rails applications?

    - by hornairs
    I'd like to develop a number of non-trivial Rails applications which all implement a core set of functionality but each have certain particular customizations, extensions, and aesthetic differences. How can I pull the core functionality (models, controllers, helpers, support classes, tests) common to all these systems out in such a way that updating the core will benefit every application based upon it? I've seen Rails Engines but they seem to be too detached, almost too abstracted to be built upon. I can seem them being useful for adding one component to an existing app, for example bolting on a blog engine to your existing e-commerce site. Since engines seem to be mostly self contained, it seems difficult and inconvenient to override their functionality and views while keeping DRY. I've also considered abstracting the code into a gem, but this seems a little odd. Do I make the gem depend on the Rails gems, and the define models & controllers inside it, and then subclass them in my various applications? Or do I define many modules inside the gem that I include in the different spots inside my various applications? How do I test the gem and then test the set of customizations and overridden functionality on top of it? I'm also concerned with how I'll develop the gem and the Rails apps in tandem, can I vendor a git repository of the gem into the app and push from that so I don't have to build a new gem every iteration? Also, are there private gem hosts/can I set my own gem source up? Also, any general suggestions for this kind of undertaking? Abstraction paradigms to adhere to? Required reading? Comments from the wise who have done this before? Thanks!

    Read the article

  • In Rails 3, how does one render HTML within a JSON response?

    - by ylg
    I'm porting an application from Merb 1.1 / 1.8.7 to Rails 3 (beta) / 1.9.1 that uses JSON responses containing HTML fragments, e.g., a JSON container specifying an update, on a user record, and the updated user row looks like . In Merb, since whatever a controller method returns is given to the client, one can put together a Hash, assign a rendered partial to one of the keys and return hash.to_json (though that certainly may not be the best way.) In Rails, it seems that to get data back to the client one must use render and render can only be called once, so rendering the hash to json won't work because of the partial render. From reading around, it seems one could put that data into a JSON .erb view file, with <%= render partial % in and render that. Is there a Rails-way of solving this problem (return JSON containing one or more HTML fragments) other than that? In Merb: only_provides :json ... self.status = 204 # or appropriate if not async return { 'action' => 'update', 'type' => 'user', 'id' => @user.id, 'html' => partial('user_row', format: :html, user: @user) }.to_json In Rails?

    Read the article

  • creating tables in ruby-on-rails 3 through migrations?

    - by fayer
    im trying to understand the process of creating tables in ruby-on-rails 3. i have read about migrations. so i am supposed to create tables by editing in the files in: Database Migrations/migrate/20100611214419_create_posts Database Migrations/migrate/20100611214419_create_categories but they were generated by: rails generate model Post name:string description:text rails generate model Category name:string description:text does this mean i have to use "rails generate model" command everytime i want to create a table? what if i create a migration file but want to add columns. do i create another migration file for adding those or do i edit the existing migration file directly? the guide told me to add a new one, but here is the part i dont understand. why would i add a new one? cause then the new state will be dependent of 2 migration files. in symfony i just edit a schema.yml file directly, there are no migration files with versioning and so on. im new to RoR and want to get the picture of creating tables. thanks

    Read the article

  • Rails: Added new Action in Controller, but there is no path?

    - by Newbie
    Hello! I try to do following: A user is on his profile page. Now he edits his profile. He klicks on update and the data is saved. Now I want to redirect the user to another kind of profile-edit-page. I did the following in my users_controller.rb: def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'User was successfully updated.' if(@user.team_id != nil) format.html { redirect_to(@user) } else format.html { redirect_to choose_team_path } end format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end def choose_team @user = User.find(params[:id]) end I created a view: /users/choose_team.html.erb Now I get the following error: undefined local variable or method `choose_team_path' for #<UsersController:0x1f56650> So I added choose_team to my routes.rb: map.choose_team 'choose-team', :controller => 'users', :action => 'choose_team' Now, after submitting my first edit form, it redirects me to http://localhost:3000/choose-team and I get following error: Couldn't find User without an ID What I want: If a user has no team_id, he should be redirected to my choose_team.html.erb for choosing a team, else he should be redirected to his profile/show. How to do this?

    Read the article

  • is_admin? function in rails? - undefined method Error

    - by Newbie
    Hello! At the moment, I am creating some kind of admin panel/backend for my site. I want to do the following: Only admins (a user has a user_role(integer) -- 1 = admin, 2 = moderator, 3 = user) can see and access a link for the admin panel. So I created an admin_controller. In my admin controller I created a new function called is_admin?: class AdminController < ApplicationController def admin_panel end def is_admin? current_user.user_role == 1 end end my route looks like. map.admin_panel '/admin-panel', :controller => 'admin', :action => 'admin_panel' and in my _sidebar.html.erb (partial in applicaton.html.erb) I created the link: <%= link_to "Admin Panel", :admin_panel unless is_admin? %> Now I get an error called: undefined method `is_admin?' Where is the problem? Please help me solving this problem!

    Read the article

  • How can I store Rails uploads on a remote server (and not a common cloud host)?

    - by joshee
    I would like to store uploads from a Rails application on a different server than my application server. I want to keep costs to a minimum and host this other server in-house. I am planning to use Carrierwave for uploads. It seems Carrierwave interfaces with Fog for remote hosts. Is there a way I could set the other server to act as a Fog provider? How would I go about this setup? Or, is there some better and easier way to go about all this?

    Read the article

  • How can I pretty print erb in BBedit indenting rails tags and not just markup?

    - by Andres Diez
    I want to re-indent my code but the rails tags <% foo %> get aligned to the left with no indentation. What I'm using is: markup utilities format pretty print Does anyone know if there is a way to reconfigure this behavior? UPDATE: I just found this out but cant seem to get it working: "The 'Pretty print' option for Markup - Utilities - Format is now implemented internally using a Dreamweaver-style source format profile. This affords slightly prettier output than was possible before. Advanced users can override the factory format profile by placing an appropriately constructed file at ~/Library/Application Support/BBEdit/SourceFormat.profile." I opened the bbedit app package, found the file, copied it to the folder indicated in "application support" and tweaked the desired indentation width just as a test before touching anything else, and it doesnt seem to do anything.

    Read the article

  • How do you determine how long it is taking Apache to forward a request to Phusion Passenger?

    - by dan
    I have a Ruby on Rails website that is serving requests relatively fast within Rails. The completion time for a Rails request is about 130ms. But the request still takes a long time because of the time it takes the Apache server in front of the Phusion Passenger instances to hand off the request to Rails. How can I measure how long it takes Apache to hand off the request to Rails via Passenger? And how can I speed this up if it's slow. Yes, I plan on switching to nginx, but I need a temporary fix.

    Read the article

  • Ruby on Rails - How to migrate code from float to decimal?

    - by user1723110
    So I've got a ruby on rails code which use float a lot (lots of "to_f"). It uses a database with some numbers also stored as "float" type. I would like to migrate this code and the database to decimal only. Is it as simple as migrating the database columns to decimal (adding a decimal column, copying float column to decimal one, deleting float column, renaming decimal column to old float column name), and replacing "to_f" with "to_d" in the code? Or do I need to do more than that? Thanks a lot everyone Raphael

    Read the article

  • How to protect Ruby on Rails code on external server?

    - by Phil Byobu
    I have to deploy a Ruby on Rails Applications on a client's server and I do not want them to be able to view or modify the source code. How would you protect the code technically? I thought about building a linux-based virtual machine with an encrypted filesystem where the application code resides. The client has no root access, or direct access to the system at all. All services start automatically and the application is ready to use. What would you suggest?

    Read the article

< Previous Page | 117 118 119 120 121 122 123 124 125 126 127 128  | Next Page >