faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<FromGitter> <ok2094> What does this mean? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b31a00b72b31d3691f39d61]
<FromGitter> <faustinoaq> @ok2094 This message means that crystal compiler can't infer ivar type, so you should declare it like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b31b10bce3b0f268d434db6]
faustinoaq has joined #amber
faustinoaq has quit [Client Quit]
<FromGitter> <ok2094> Thanks
<FromGitter> <AizuddinBadry> > ``` ⏎ Fetching https://github.com/amberframework/micrate.git ⏎ Unhandled exception: Error opening file '/Users/aizuddinbadry/.cache/shards/github.com/amberframework/micrate.git/config' with mode 'r': No such file or directory (Errno) ⏎ from Crystal::System::File::open<String, String, File::Permissions>:Int32 ⏎ from File::new<String, String, File::Permissions, Nil, Nil>:File ...
<FromGitter> <AizuddinBadry> @faustinoaq i have problem when updating amber to v0.8.0 and crystal v0.25.0
<FromGitter> <conradwt> @faustinoaq Is there a document which has the list of external dependencies for `Amber` other than `crystal`, `shards`, `redis`, and `postgresql`?
snsei has joined #amber
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <shobhitic> @conradwt Wouldn't `shard.yml` file be enough for it? ⏎ ⏎ It shows :- ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b31e4437da8cd7c8c6e2e63]
<FromGitter> <shobhitic> I've got a very basic crystal question here. ⏎ ⏎ I have a field in db which stores JSON text (input by user) as a String. Now, I want to send it back when there's a call at a certain API. To do that, I am having to write `respond_with { json JSON.parse(json_host.data) }`, but the compiler doesn't compile it because `json_host.data` can be a nil value too. ⏎ ⏎ ```code paste, see link``` ...
<FromGitter> <shobhitic> Thanks for letting me blabber. I was looking for the `json_host.as(String)` method.
prutheus has joined #amber
<prutheus> Hey @faustinoaq , how is it looking? ;)
<FromGitter> <conradwt> @shobhitic I'm interested in 3rd part libraries which need to be installed prior to installing `Amber`. For example, `PostgreSQL` and `Redis`.
<FromGitter> <shobhitic> @conradwt Redis is required? :O I don't have it installed and everything works...
feepbot has quit [Ping timeout: 268 seconds]
feepbot has joined #amber
<FromGitter> <eliasjpr> > @shobhitic I'm interested in 3rd part libraries which need to be installed prior to installing `Amber`. For example, `PostgreSQL` (i.e. default database) and `Redis` (required for session store). ⏎ ⏎ @conradwt are you referring to the docs or an actual amber app?
<FromGitter> <eliasjpr> > BTW, What's the Amber equivalent of `root_url` or any other `_url` methods from Rails? Something which takes into account the requesting domain?
<FromGitter> <shobhitic> @eliasjpr Is there a link to the discussion? I'd like to help
<FromGitter> <eliasjpr> give me a sec I swear @faustinoaq opened an issue for this
<FromGitter> <eliasjpr> @shobhitic you can post your thoughts here https://github.com/amberframework/amber/issues/778
faustinoaq has joined #amber
<FromGitter> <faustinoaq> prutheus, It's looking fine. I'll publish my code today. I'm just fixing some recipes issues in amber 😅
<FromGitter> <faustinoaq> @shobhitic You can also use `.not_nil` (https://crystal-lang.org/api/0.25.0/Object.html#not_nil%21-instance-method) or handle the nil using `if var` (https://crystal-lang.org/docs/syntax_and_semantics/if_var.html)
<FromGitter> <shobhitic> Thanks! While going through `if var`, I saw this :- ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Why can `a` be nil here in the if condition? [https://gitter.im/amberframework/amber?at=5b32256759799e701742ea8b]
<FromGitter> <faustinoaq> > I'm interested in 3rd part libraries which need to be installed prior to installing Amber ⏎ ⏎ @conradwt Actually you don't need them, until you use them in your source code. I mean in crystal the "shards" (gems) are code build at compile time, we require a lot of shards mainly because the *amber cli* is embedded with *amber lib*, so you can do `shards build amber` in your project and use it locally
<FromGitter> <faustinoaq> @conradwt In theory we could be able to create a minimal amber (just lib) with a minimal set of dependencies (without cli)
<FromGitter> <faustinoaq> @shobhitic because `a` is nil and won't enter inside if condition ⏎ ⏎ ```if a # `a` is nil ⏎ # `a` never reaches this ⏎ end``` [https://gitter.im/amberframework/amber?at=5b3226a5ce3b0f268d44468c]
<FromGitter> <faustinoaq> BTW, you can play with those examples on https://play.crystal-lang.org
<FromGitter> <eliasjpr> We have to start using stack overflow to have these kind of questions
<FromGitter> <shobhitic> > We have to start using stack overflow to have these kind of questions ⏎ ⏎ Yes, I am sorry
<FromGitter> <eliasjpr> Moving forward let’s questions on stackoverflow we can answer them here as well but at least we have it documented
<prutheus> faustinoaq: nice :D
<FromGitter> <damianham> In the latest granite how do I now do "select distinct x from y" ?
snsei has joined #amber
<FromGitter> <robacarp> I don’t think granite has a dsl for distinct
<FromGitter> <robacarp> It wouldn’t be too bad to add to the query builder but that hasn’t been built out for MySQL yet
<FromGitter> <drujensen> @damianham You can create a query object that uses the `select` macro that returns the results mapped into this new object.
<FromGitter> <shobhitic> Off topic - Just deploying a service I had been writing for the past two days to production 😄
<FromGitter> <drujensen> @shobhitic best of luck!
<FromGitter> <damianham> @drujensen I can - but that would imply a new object (and thus a new source code file) for every query like this - probably sub optimal
<FromGitter> <drujensen> Is there a case when it would be DISTINCT and others when it wouldn’t but they would map to the same fields?
<FromGitter> <damianham> I thought the previous way I was using it ⏎ ⏎ ```sections = Post.all("select distinct section from posts") ``` ⏎ ⏎ was nice and easy [https://gitter.im/amberframework/amber?at=5b32449eaeb8fa0c0743a156]
<FromGitter> <drujensen> oh, did that change?
<FromGitter> <damianham> actually the code I was using was ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b3244df5862c35f47c987ae]
<FromGitter> <drujensen> The last example should work still
<FromGitter> <drujensen> you are just getting the results back as strings
<FromGitter> <drujensen> What error are you getting?
<FromGitter> <damianham> I had a compile error - something like can't define a def inside a def ⏎ I refactored so I fixed my problem but I liked the old way as I used the db engine to get a distinct list of fields rather than a Hash in code
<FromGitter> <drujensen> I agree. I exposed the `query` so you can do this
<FromGitter> <damianham> yes it is broken
<FromGitter> <drujensen> do you have time to write up a bug?
<FromGitter> <damianham> yes OK - I think the issue is with the introduction of the query macro in select.cr
<FromGitter> <damianham> done
<FromGitter> <damianham> what happened to the reload Pipe - did it get removed in 0.8 ?
<FromGitter> <drujensen> @damianham thanks for opening a ticket. I will take a look after work today.
<FromGitter> <damianham> 👍
<prutheus> faustinoaq: when can i expect an upload ? :D
<faustinoaq> prutheus, I think this night, I'm at college right now :)
snsei has quit [Remote host closed the connection]
wontruefree has joined #amber
faustinoaq has quit [Ping timeout: 260 seconds]
wontruefree has quit [Quit: bye]
<FromGitter> <conradwt> @shobhitic Are you doing anything with sessions? If not, then this probably will not cause any issues for you.
<FromGitter> <shobhitic> I am, but using cookies to store sessions.
<FromGitter> <shobhitic> @conradwt If you use any kind of flash, you will need to use sessions
<prutheus> @faustinoaq I am away from my main pc now, do you get it done in the next 2 hours or should i wait a bit longer?
faustinoaq has joined #amber
<FromGitter> <conradwt> @shobhitic You're still not using sessions here. Sessions are kept on the server where as cookies are local to the browser. Cookies also have privacy concerns because any sites can access your cookie data and require defensive measures. Just something to think about because the EU policies are in place.
<FromGitter> <shobhitic> @conradwt Umm. AFAIK you can encrypt your session data and store it in cookie. Rails does it. Not talking about legal implications here, but technically it is a session stored in cookie. How do you define session?
<FromGitter> <shobhitic> According to docs - ⏎ ⏎ > Session: A Hash that specifies the session storage mechanism, expiration and key to be used for the application. The `key` specifies the name of the cookie to be used defaults to "amber.session". The store can be `encrypted_cookie`, `signed_cookie` or `redis`. Expires when set to 0 means this is indefinitely and is expressed in seconds.
<FromGitter> <conradwt> @shobhitic In Rails 5.2, I use Devise for all things dealing with user data and tend to never set anything on the browser. If one can access it, it can be decrypted given time. Next, I tend to have 'Block all cookies' set on all on my browsers.
<FromGitter> <shobhitic> @conradwt Devise doesn't dictate how session is stored. It just uses session as given by Rails, which by default is in an encrypted cookie, just like in Amber.
<FromGitter> <shobhitic> To all - Do flashes work different in `--release` binary vs using them with `amber w`?
<FromGitter> <conradwt> @shobhitic By default, sessions are stored on server.
<FromGitter> <shobhitic> @conradwt http://guides.rubyonrails.org/security.html#encrypted-session-storage ⏎ ⏎ > The CookieStore saves the session hash directly in a cookie on the client-side. The server retrieves the session hash from the cookie and eliminates the need for a session ID. That will greatly increase the speed of the application, but it is a controversial storage option and you have to think about the security
<FromGitter> ... implications and storage limitations of it:
<FromGitter> <shobhitic> Be default, Rails stores session in a cookie. PHP stores on server I think
<FromGitter> <shobhitic> Just start your Rails app, open the network tab in browser and access your app, you'll see a "session" cookie, or something like that with gibberrish encrypted values
<FromGitter> <conradwt> @shobhitic My template for Rails 4.0 to current using default server side session.
<FromGitter> <shobhitic> @conradwt Ah. Must be configured in your template, but by default cookie is used. See: https://stackoverflow.com/questions/21783016/how-does-rails-devise-handle-cookie-sessions
<FromGitter> <conradwt> @shobhitic I disable all cookies in all my browsers.
<FromGitter> <paulcsmith> So the session is *not* encrypted. That is usually enough but it means you should not store anything sensitive in the session without changing it to use encrypted_cookie
<FromGitter> <shobhitic> Yes, I understand that but how does server know which is my session? How does it identify my browser/
<FromGitter> <conradwt> @shobhitic The session is stored on the server without a database field.
<FromGitter> <shobhitic> Let it be
wontruefree has joined #amber
<robacarp> the server uses a cookie with a session identifier sent to the browser
<robacarp> that id can then be used to look up a session in ram, redis, database, etc
<FromGitter> <shobhitic> @robacarp Yes, so if you completely disable cookie, the concept of authentication will cease to exist, correct?
<robacarp> yes, but there are a couple different kinds of cookies
<robacarp> I believe that browsers don't disable session cookies when you disable cookie storage
<robacarp> so the cookies still happen, but they don't persist when you close the browser
<FromGitter> <shobhitic> Ahh!
<FromGitter> <shobhitic> This makes sense.
<robacarp> http session storage is pretty lowel stuff, it's hard to disable
<FromGitter> <G4BB3R> Hello folks. Just installed Amber but I am having problems with basic routing. This code should serve everything in my public folder, but I cannot reach my robots.txt file ⏎ ⏎ `````` [https://gitter.im/amberframework/amber?at=5b329612ce3b0f268d4585e8]
<FromGitter> <G4BB3R> I am having a js error in amber watch ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b329663ce3b0f268d4586a6]
<FromGitter> <conradwt> @faustinoaq Just submitted the PR for the Shards Port and I'm limiting to macOS 10.12 or greater for now. Although, I have every version of macOS starting with 10.0. https://github.com/macports/macports-ports/pull/2101
<faustinoaq> @conradwt Oh very nice, Thank you!
<FromGitter> <rishavs> For granite, is the `save!` feature not supposed to work within a begin/raise block? my code is; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b3296a6ad21887018e0a169]
<FromGitter> <conradwt> @faustinoaq I'll wait until that Shards PR gets approved before submitting the Amber PR to MacPorts.
<FromGitter> <conradwt> @Rushav
<FromGitter> <rishavs> No test cases. :/ ⏎ For me this works as expected; ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/amberframework/amber?at=5b3298c4ce3b0f268d45900f]
<FromGitter> <rishavs> If I can raise a normal exception using `!` then I would be able to remove that unnecessary if/else block
<FromGitter> <conradwt> @rishavs Which version of granite?
<FromGitter> <rishavs> granite: ⏎ ⏎ ```github: amberframework/granite ⏎ version: 0.12.1``` [https://gitter.im/amberframework/amber?at=5b3299415862c35f47ca8a59]
<FromGitter> <shobhitic> Just deployed my first app within 2 days of picking up amber. 😄 https://jsonkeeper.com/
<FromGitter> <conradwt> @shobhitic Great, that's awesome!!!
<robacarp> that's a neat idea for an app @shobhitic
marenz has joined #amber
<FromGitter> <shobhitic> There was a very weird bug wrt `flash` that I found in prod, which was absent in dev. ⏎ ⏎ Do shards simply install the master branch when we're installing things?
<FromGitter> <conradwt> @shobhitic Some shards install from master and some use a particular release from what I have seen.
<FromGitter> <conradwt> @rishavs Do you have a line like this in you `shards.yml`? ``` granite: ⏎ ⏎ ```github: amberframework/granite`````` [https://gitter.im/amberframework/amber?at=5b329d6b72b31d3691f6047e]
<FromGitter> <rishavs> eh? yes I do. ⏎ ⏎ ``` granite: ⏎ github: amberframework/granite``` [https://gitter.im/amberframework/amber?at=5b329d980168e70c08f10601]
<FromGitter> <rishavs> I am on 12.1
faustinoaq has quit [Ping timeout: 240 seconds]
<robacarp> @shobhitic shards are hopefully pegged to a release tag in git
<robacarp> what flash bug did you see?
<prutheus> Is it possible to have multiple WebSocket::Channels connected to one Websocket?
<prutheus> I have defiend multiple channels and wanted to connect them into one socket by putting for each channel at the socket: channel "name", NameChannel at the first line in the class
<robacarp> @faustinoaq is probably the one around with the most websocket experience in amber
<prutheus> I have the problem that when i wanna join both channels I just join the data channel, doesnt matter if my websocket client has the topic 'calculation'
<FromGitter> <G4BB3R> ``````
faustinoaq has joined #amber
<prutheus> Hey faustinoaq has you read my problem with websocket and multiple channels?
<robacarp> @G4BB3R are you using the csrf tag in your forms?
<FromGitter> <G4BB3R> I don't have front-end yet! I am trying to access my API from the browser
<FromGitter> <G4BB3R> The only way to respond with json is ```respond_with { json pets.to_json }``` ? There is not a simpler way?
<robacarp> aah, yeah for json api endpoints, you'll want ot disable the csrf pipe
<FromGitter> <conradwt> @G4BB3R I thought one could do `respond_with { pets.to_json }`.
<FromGitter> <eliasjpr> You can but it must be a proc
<FromGitter> <conradwt> @eliasjpr Thanks for the clarification here.
<FromGitter> <eliasjpr> We thought of adding those simpler helper methods but we decided not to
<FromGitter> <conradwt> @rishavs I would recommend filing an issue against the `Granite` shard because I'm seeing a similar issue here.
<FromGitter> <eliasjpr> Instead if you want to render JSON from the controller without using respond_with you can simply object.to_json but must set the corresponding response headers
<FromGitter> <eliasjpr> def index; response.headers[“content-type”]=“application/json”; pets.to_json; end
<FromGitter> <eliasjpr> ^ Im on my phone sorry for the lack of styling to that code
<FromGitter> <G4BB3R> Thx! Can I avoid this header everytime setting it in the plug section? routes.cr
<FromGitter> <G4BB3R> Is there a plug for the header? ⏎ ⏎ `````` [https://gitter.im/amberframework/amber?at=5b32b0dd479ca26689821d4c]
<FromGitter> <eliasjpr> To set all request as json?
<FromGitter> <eliasjpr> I guess I’m a controller you can define a before or after action to set the headers
<FromGitter> <G4BB3R> Yes. hmm ill try to search it. thx again
<FromGitter> <eliasjpr> Gabriel see ^
<FromGitter> <G4BB3R> Seems to be working, thx! =) ⏎ ⏎ ``` all { response.headers["Content-Type"] = "application/json" } ⏎ end `````` [https://gitter.im/amberframework/amber?at=5b32b37daeb8fa0c0744d9b4]
<FromGitter> <conradwt> It may be a good exercise to research what headers Elixir is using for both brower and api pipelines. Just a thought to consider.
marenz has quit [Ping timeout: 264 seconds]
<FromGitter> <eliasjpr> I just saw their docs
<FromGitter> <eliasjpr> And they have a plug to set response headers
<FromGitter> <eliasjpr> We should be able to create a plug that takes a hash
<FromGitter> <eliasjpr> Feel free to contribute the ResponseHeader plug
faustinoaq has quit [Quit: IRC client terminated!]
prutheus has quit [Quit: Page closed]
wontruefree has quit [Quit: bye]
ttt4 has joined #amber
ttt4 has quit [Client Quit]