How to do a Post/Redirect/Get using Sinatra?

Redirect in Sinatra is the most simple to use. So the code below can explain: require ‘rubygems’ require ‘sinatra’ get “https://stackoverflow.com/” do redirect “http://example.com” end You can also redirect to another path in your current application like this, though this sample will delete a method. delete ‘/delete_post’ do redirect ‘/list_posts’ end A very common place … Read more

What does the * (star) mean in Ruby? [duplicate]

Variable Length Argument List, Asterisk Operator The last parameter of a method may be preceded by an asterisk(*), which is sometimes called the ‘splat’ operator. This indicates that more parameters may be passed to the function. Those parameters are collected up and an array is created. The asterisk operator may also precede an Array argument … Read more

Method to parse HTML document in Ruby?

There is no built-in HTML parser (yet), but some very good ones are available, in particular Nokogiri. Meta-answer: For common needs like these, I’d recommend checking out the Ruby Toolbox site. You’ll notice that Nokogiri is the top recommendation for HTML parsers

vim ruby mismatch on Mac High Sierra

This worked for me. YMMV brew uninstall –purge macvim brew install macvim [amended] Regarding the upgrade alone option, that may work if you don’t have the current version already. The –purge forces a removal and complete reinstall. Also, the build from source option, while it may work, you now own your own mac-vim static snapshot … Read more

Unable to update gems on production server

The instructions are probably a bit confusing. It’s saying that you’ve modified your Gemfile on your development machine and just pushed those changes rather than running bundle install BEFORE committing the changes. By running bundle install you will update your Gemfile.lock file. This should be pushed to your server as it’s more important than Gemfile. … Read more

Array Attribute for Ruby Model

Create a model with a text field > rails g model Arches thearray:text invoke active_record create db/migrate/20111111174052_create_arches.rb create app/models/arches.rb invoke test_unit create test/unit/arches_test.rb create test/fixtures/arches.yml > rake db:migrate == CreateArches: migrating =================================================== — create_table(:arches) -> 0.0012s == CreateArches: migrated (0.0013s) ========================================== edit your model to make the field serialized to an array class Arches < … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)