These are chat archives for padrino/padrino-framework

20th
Jun 2017
Sushant Bajracharya
@sushant12
Jun 20 2017 09:30
I hope to contribute more to the community :)
Sushant Bajracharya
@sushant12
Jun 20 2017 10:44
has anyone used dotenv with padrino ? i am havin some issues running rake sq:create tasks , since I am referencing the username and password for db connection in the .env file
Sushant Bajracharya
@sushant12
Jun 20 2017 10:56
turns out that dotenv does not override the sys env variable
just updated the name in the env to fix the issue
padrinobot
@padrinobot
Jun 20 2017 12:23
wikimatze thanks sushant12, really appreciate your help
wikimatze never used dotenv
Sushant Bajracharya
@sushant12
Jun 20 2017 12:58
@wikimatze in the padrino omniauth doc
account = Account.find_by_provider_and_uid(auth["provider"], auth["uid"]) ||
            Account.create_with_omniauth(auth)
will it make more sense to move the find_by.. inside a method inthe model
to decople, i dont know if that is a right term for this
i am suing sequel so i wrote something like this
class Account < Sequel::Model
  def self.create_or_find_from_omniauth(auth)
    find(uid: auth['uid']) || create do |account|
      account.uid      = auth["uid"]
      account.name    = auth["info"]["name"] if auth["info"]
      account.email    = auth["info"]["email"] if auth["info"]
    end
  end
end
account = Account.create_or_find_from_omniauth(auth)
if there are other better alternative, please let me know
Sushant Bajracharya
@sushant12
Jun 20 2017 13:32
if i want to create a base controller in padrino, how do i do that?
padrinobot
@padrinobot
Jun 20 2017 14:06
adam12 @sushant12 not possible afaik
Sushant Bajracharya
@sushant12
Jun 20 2017 14:07

any other alternative? @adam12

      def controller(*args, &block)
        if block_given?
          with_new_options(*args) { instance_eval(&block) }
        else
          include(*args) if extensions.any?
        end
      end

what is extensions.any?

padrinobot
@padrinobot
Jun 20 2017 14:09
adam12 @sushant12 What are you looking to share? auth?
Sushant Bajracharya
@sushant12
Jun 20 2017 14:10
@adam12 I want to create a current_user function which tracks a user session.
if the session is nil, user will see the logout btn
padrinobot
@padrinobot
Jun 20 2017 14:11
adam12 @sushant12 maybe use a custom helper for this?
Sushant Bajracharya
@sushant12
Jun 20 2017 14:12
thanks @adam12 , just out of curiosity, why is there no support for base controller?
padrinobot
@padrinobot
Jun 20 2017 14:13
adam12 @sushant12 There is no inheritance with the Padrino Router, at least that I have seen. It's a DSL that likely does a module_eval.
Sushant Bajracharya
@sushant12
Jun 20 2017 14:14
neat. thanks @adam12
padrinobot
@padrinobot
Jun 20 2017 14:14
adam12 @sushant12 You might be able to use plain Ruby here, where you include BaseController or something. I haven't tried it.
Sushant Bajracharya
@sushant12
Jun 20 2017 14:18
@adam12 , used plain ol` ruby like u said
thanks
padrinobot
@padrinobot
Jun 20 2017 14:19
adam12 @sushant12 nice :)
Sushant Bajracharya
@sushant12
Jun 20 2017 14:21
decided to revert to helpers as it looks like a better fit and the method call would aloe not look ugly like Fuitter::Base.current_user
padrinobot
@padrinobot
Jun 20 2017 14:23
adam12 @sushant12 You might have been able to get around that with a Fruitter.send(:include, your_module), but I don't know for sure if it would of worked
adam12 Glad the helper style worked tho.
padrinobot
@padrinobot
Jun 20 2017 20:08
adrianvalenz_ Hi guys!
adam12 adrianvalenz_: o/
adrianvalenz_ @adam12 hmm? lol
adam12 hmmm?
adam12 \o/
padrinobot
@padrinobot
Jun 20 2017 20:14
adam12 adrianvalenz_: whatup
adrianvalenz_ adam12: nothing much just surfing through irc, trying to a little more at least
adam12 adrianvalenz_: Cool :)
adrianvalenz_ I noticed some inconsistencies in the blog tutorial for padrino docs. I forked and cloned it to fix it and will try to do a pull request today or tomorrow.
padrinobot
@padrinobot
Jun 20 2017 20:19
adam12 adrianvalenz_: Thanks. It's hard to keep up to date, tho I thought we had got them all.
adam12 But we just switched from ActiveRecord to Sequel so maybe we missed some.
padrinobot
@padrinobot
Jun 20 2017 20:38
adrianvalenz_ Yea it is the second paragraph of "Project Generation" where it mentions will be using ActiveRecord and Slim when it is Sequel and Haml. The rest of it looked good.