Francisco Quinones

Joined

7,370 Experience
40 Lessons Completed
2 Questions Solved

Activity

Posted in store_accessor with jsonb nesting

<%= f.fields_for :foo_permit, OpenStruct.new(f.object.foo_permit || {}) do |permits| %>

Posted in store_accessor with jsonb nesting

So Im building a user permits column with jsonb.

jsonb column

    bar_permit: {
       key1:      [],
       key2:       "Bar",
       key3:       false,
       key4:       false,
       key5:       false
      },
    foobar_permit: {
      key1:      [],
      key2:       "Bar",
      key3:       false,
      key4:       false,
      key5:       false
      }
    }
class Foo < ActiveRecord::Base
  serialize :permits, HashSerializer
  store_accessor  :permits, :bar_permit, :foobar_permit
end

with the HashSerializer I can call the first hash keys as table columns

example:

 foo.bar_permit
 or 
 foo.foobar_permit
class HashSerializer
  def self.dump(hash)
    hash.to_json
  end

  def self.load(hash)
    (hash || {}).with_indifferent_access
  end
end

now I need to make the bar_permit and the foobar_permit to a hash with preset keys

I add these methods to the model so I can have a {key:value} for bar_permits

def bar_permit=(attributes)
    super
    value = []
    attributes.each do |index, attrs|
      value << attrs
    end
    write_attribute(self.permits[:bar_permit], value)
  end

  def bar_permit
    super
    self.permits[:bar_permit]= {
      key1:      [],
      key2:       "Bar",
      key3:       false,
      key4:       false,
      key5:       false
    }
  end

Is this the correct way of making the attributes behave as hash?
How can I make the form helpers work with the keys of the virtual attributes as fields.

The first Event with all the info is created on the Event model and when is the date of the even I use the build a recurrent is like a transaction of the event and is stored in the db. The Event just has a temp on the fly presenter. the recurrent es more like a record of what happen that day. That's my approach to this on my businesses logic.

I haven't tried without recurrent event. All my schedule have recurrent. I can add a gist with my setup and you can check it out.

I'm using the recurring_select + ice_cube gems on my app and implement the full_calendar for the interface. schedule. This is one of the best combination so far.

Posted in Create a welcome page with a tour/get started

Thank you Chris for the feed back.

this part is what I'm most interest:

marked off like intro_complete once they're finished with the tour. 
You can display the tour the first time and when they close out of it make
an AJAX request to mark that column as true

Posted in Create a welcome page with a tour/get started

Hi, I was thinking of a way when the user login for the first time they get redirect to a welcome page where they take some steps into maybe a tour or fill some important fields to getting started.

What is a good approach, technics or tools to show the user how to use my interface.
Any article, examples will be nice. Im using devise for users.

or

Posted in How to setup SSL with a rails app

Got it working Chris. Just redo same step and got it working. thank you.

Posted in How to setup SSL with a rails app

Thank you, Chris as always for the quick reply.

Posted in How to setup SSL with a rails app

I chris having a little problem. So I was following the Docs.

  1. got the CSR from heroku
  2. I got a godaddy cert ssl
  3. Update the DNS (heres where im having problem.)
Standard Wildcard SSL from godaddy
CSR files
server.csr
.server.key
server.pass.key
heroku certs:info
Fetching SSL certificate hypsilophodon-49522 info for myapp done
Certificate details:
Common Name(s): *.myapp.com
                myapp.com
Expires At:     ...
Issuer:        ...Go Daddy Secure Certificate Authority - G2
Starts At:      ...
Subject:        /OU=Domain Control Validated/CN=*.myapp.com
SSL certificate is self signed.
heroku certs
Name                               Common Name(s)                  Expires               Trusted  Type
....-49522  *.myapp.com, myapp.com                         ...                        False    SNI
On my DNS Management
CNAME   *   myapp.herokuapp.com
CNAME   www hbquality.herokuapp.com
Your certificate *.myapp.com expires on ...
Ensure you've updated your DNS to reflect the new target name. See domain table below.
heroku panel settin
Domain Name DNS Target
*.myapp.com   wildcard.myapp.com.herokudns.com
myapp.com  myapp.com.herokudns.com
www.myapp.com www.myapp.com.herokudns.com


I think im doing some setup wrong.

UPDATE:
Godaddy Cname

www.myapp.com.herokudns.com
wildcard.myapp.com.herokudns.com

Posted in How to setup SSL with a rails app

Chris Thanks as always.

Posted in How to setup SSL with a rails app

So I have a ssl certification that I want to apply to my rails app. Im using puma on Heroku.

Posted in User create Dynamic Role base

Hi! So my app uses CanCanCan and Devise for working with users. Now the app needs to have a feature where users can create role. How can I approach this new task.

Example:
Admin(User) can create Roles with a permission list (can and can't with on/off boolean) without redeploying the app.

Posted in Message Templates Discussion

thanks Chris love this one, got it working in mins.

Posted in Sending Emails with SMTP and Sendgrid Discussion

jajajaj Chris Your the man. I was just switching from my simple gmail account to using sendgrid and now this episode show up. :) very very happy.

more like this plis!

Posted in Solving FizzBuzz in Ruby Discussion

love it

Posted in How to migrate from Heroku to Digital Ocean

thnx Chris for taking the time.

Posted in How to migrate from Heroku to Digital Ocean

Chris, I'm thinking of moving to digital Ocean from Heroku but my knowledge on this topic is cloudy. Can you tell us about the differences between the 2 service? and benefit.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.