Skip to content

Curly Braces

Golden nuggets where no entry is longer than my expected attention span

  • Articles
  • Contact Me!
  • Policy
  • Internal

Category: Ruby on Rails

Installing a certificate using LetsEncrypt on a Ubuntu server with Apache (New version 2022-08-15)

Posted on October 14, 2021 by Peter Andersson

Running webservers on own hardware I develop a lot of websites, and I run them on my own hardware (a Ubuntu Server). When developing (on […]

Continue reading »
0
Apache, Development, Ruby on Rails, Web

Massuploading pictures using ActiveStorage

Posted on December 1, 2020 by Peter Andersson

ActiveStorage is a gem, I really think so. Before AS, whenevener I needed to attach a “blob” (image or other document) to a model it […]

Continue reading »
0
Development, HTML and CSS, Ruby, Ruby on Rails

Ruby and Rails development environment

Posted on March 6, 2020 by Peter Andersson

How do you setup VS Code, which is a great code editor, for Ruby development? Well you start by installing these gems: gem install solargraph […]

Continue reading »
0
Development, Ruby on Rails, Visual Studio Code

Rubys magic language

Posted on September 30, 2019 by Peter Andersson

This is a piece of code I keep to remind me of the magic in Ruby. class Main # you can dynamically define methods with […]

Continue reading »
0
Development, Ruby, Ruby on Rails

Multiple select listboxes in Rails

Posted on March 29, 2019 by Peter Andersson

Since I think the documentation is lacking and I always have to rely on Stackoverflow every time I want to use it, I keep this […]

Continue reading »
0
Development, Ruby on Rails

Creating your own tag helper in Rails

Posted on March 29, 2019 by Peter Andersson

Lets say you get sick and tired of writing this in your views: <div class=”field”> <%=form.label :location %> <%=form.text_field :location %> </div> and instead you […]

Continue reading »
0
Development, Ruby, Ruby on Rails

Creating a DSL in Ruby

Posted on February 14, 2019 by Peter Andersson

Creating a Domain Specific Language has been on my TODO-list for a long time! Ruby is the perfect language for this task I have collected […]

Continue reading »
0
Development, Ruby on Rails

Make your own Rails View helpers

Posted on November 14, 2018 by Peter Andersson

Rails helpers like image_url, link_to, form_with, fields_for etc are nifty little “macros” that makes your Rails code smaller and clearer. I mean, who doesn’t prefer […]

Continue reading »
0
Development, HTML and CSS, Ruby on Rails

Array is an instance of class Class

Posted on September 3, 2018 by Peter Andersson

If the title to this post seems impossible to understand, please read this conversation between Gavin Sinclair and Martin de Mello. Something that was really […]

Continue reading »
0
Development, Ruby, Ruby on Rails

Gulp or Webpack?

Posted on June 14, 2018 by Peter Andersson

First of all, Gulp and Webpack are not beasts of the same kind. Gulp is a task runner, which you can use for various tasks […]

Continue reading »
0
Development, Javascript, Ruby on Rails

Mixing server-rendering of pages with an API in Rails

Posted on May 31, 2018 by Peter Andersson

This is the recommended way of serving API-endpoints in a regular Rails application. Note the {format:json} in the “api” section. Rails default is {format :html} […]

Continue reading »
0
Ruby on Rails

User sign-in from SPA to Rails backend

Posted on May 29, 2018 by Peter Andersson

Intro Nowadays it is popular to create fullstack-JS applications (meaning both front- and backend written in Javascript) but what if you want to use the […]

Continue reading »
0
Ajax, Development, Javascript, Ruby on Rails

Saving nested models in Rails

Posted on May 23, 2018 by Peter Andersson

Very often, I would say almost always, you have nested models in a Web application. In  Rails, you (most often) specify it using has_many and […]

Continue reading »
0
Development, Ruby on Rails

What makes Rails a framework worth learning in 2017?

Posted on May 16, 2018 by Peter Andersson

From Quora: https://www.quora.com/What-makes-Rails-a-framework-worth-learning-in-2017   David Heinemeier Hansson, Creator of Ruby on Rails, Founder & CTO at Basecamp   The same reasons why it was a framework […]

Continue reading »
0
Development, Ruby on Rails

Simple Ajax in Rails 5.2

Posted on May 15, 2018 by Peter Andersson

I’d like to present a short and to-the-point instruction on how to add some Ajax pizazz to a simple Rails-generated page. It won’t take you […]

Continue reading »
0
Ajax, Development, Ruby on Rails

Common Rails error you will (most probably) see in your log file

Posted on April 26, 2018 by Peter Andersson

Phil Nash wrote a great article about common Rails errors and how to deal with them. The common errors are: 1. ActionController::RoutingError 2. NoMethodError: undefined […]

Continue reading »
0
Development, Ruby on Rails

Why Ruby is Great!

Posted on February 19, 2018 by Peter Andersson

The single reason why I started dating Ruby class VCR def initialize @messages = [] end def method_missing(method, *args, &block) @messages << [method, args, block] […]

Continue reading »
0
Development, Ruby on Rails

Rails relations

Posted on February 16, 2018 by Peter Andersson

problem You know when you want to select  records depending on the values of related records (like belongs_to fields) ? scenario class TradingSignal < ActiveRecord::Base […]

Continue reading »
0
Development, Ruby on Rails

Rails HATM (Has and belongs to many)

Posted on February 12, 2018 by Peter Andersson

Nested forms with HABTM and HasManyThrough Start with the models has_many :events # creates …… accepts_nested_attributes_for :events, :allow_destroy => true # creates…. attr_accessible :events_attributes # […]

Continue reading »
0
Development, Ruby on Rails

Running a script “later”

Posted on February 5, 2018 by Peter Andersson

You know how it is, you need to download a 3GB install kit, but don’t want to disturb the missuz by clogging all the bandwidth. […]

Continue reading »
0
Development, Linux, Network, Ruby on Rails

Heroku

Posted on January 1, 2018 by Peter Andersson

Heroku Rails Receipes Running a migration heroku run rake db:migrate Clearing a PG database on heroku heroku pg:reset DATABASE WARNING: Destructive action postgresql-flexible-10203 will lose […]

Continue reading »
0
Development, Heroku, Ruby on Rails

CSS and SASS in Rails

Posted on January 1, 2018 by Peter Andersson

A good article about organising CSS/SASS in Rails http://www.mattboldt.com/organizing-css-and-sass-rails/ Basically you have this in yourapp/assets/stylesheets/application.css /* NOTE: Not Application.scss */ /* *= require_self *= require […]

Continue reading »
0
Development, HTML and CSS, Ruby on Rails

Redefining Rails Models: Going Beyond Rails and Sometimes, Beyond Tables

Posted on January 1, 2018 by Peter Andersson

Harnessing ActiveRecord Outside Rails ActiveRecord, the model component of Rails, is well-known for its versatility. It can be used within Rails, of course, but did […]

Continue reading »
0
Development, Ruby on Rails

Rails Templates

Posted on December 27, 2017 by Peter Andersson

Just use them! Save a bunch of time when startiung a new project. Here’s my latest fav: Rails 5.1 with Bootstrap, Font Awesome and Devise. […]

Continue reading »
0
Development, Ruby on Rails

Rails Console tips

Posted on November 16, 2017 by Peter Andersson

Sometimes you want to test queries etc from the Rails Console that requiers you to be logged in (for example via Devise). This is how […]

Continue reading »
0
Development, Ruby on Rails

Rails Resources

Posted on October 12, 2017 by Peter Andersson

Gems you NEED 12 gems every rails developer should know 2016 7 must have gems to install on any project 8 useful ruby on rails […]

Continue reading »
0
Ruby on Rails

The problem with Rails Asset Pipeline that I always stumble upon

Posted on August 13, 2017 by Peter Andersson

You know how it is, you develop using Rails and it is going great! Tailwind and downhill, you develop with an amazing speed. Then when […]

Continue reading »
0
Ruby on Rails

Rails and Devise – Login using either username or email

Posted on August 7, 2017 by Peter Andersson

This is essentially a no-nonsense step-by-step description of the most common case from: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address 1) add a field to the User table rails generate migration […]

Continue reading »
0
Ruby on Rails

Capistrano!

Posted on April 27, 2017 by Peter Andersson

How to deploy a Rails 4 app with Git and Capistrano

Continue reading »
0
Ruby on Rails

Adding Stripe Payments to your Rails application

Posted on March 30, 2017 by Peter Andersson

If you need to process payments, for example charging the user for using your great new website, Stripe is a great contender. An alternative is […]

Continue reading »
0
Development, Ruby on Rails

Setting up 1000 Devise user accounts using fixtures

Posted on March 24, 2017 by Peter Andersson

Seting up a one Devise user (version 3.5.1 and later) is simple in file <app>/test/fixtures/users.yml: tom: id: 11 name: TestUser email: test@example.org encrypted_password: <%= Devise::Encryptor.digest(User, ‘password’) […]

Continue reading »
0
Development, Ruby on Rails

The Lazy Investor

Posted on February 18, 2017 by Peter Andersson

I have started a new project. Since I do a fair share of investing, both in futures and stocks, I have tried several different  ways […]

Continue reading »
0
Java, Ruby on Rails, Trading

Från bloggen

AI Ajax Apache bash Development Docker Git Google Gradle Heroku HTML and CSS Imaging IOS Java Javascript Linux Math MIcroservices Microsoft MySQL Network Node OSX Palmemordet Patterns Photo PHP Python Raspberry Pi React Ruby Ruby on Rails Samba Spring Boot Tankar Thoughts Trading Uncategorized Video Visual Studio Code Vue Web Wordpress XCode
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Mar    

Articles

Favourite Links

  • A Rock Solid Rails 5 API App with a React Frontend
  • Rails 5.1's form_with tag
  • Complex Rails forms
  • Rails is scalable

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Powered by WordPress and Momentous.