<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`?
<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>
<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>
<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>
<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>
<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.
<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>
<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
<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.
<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>
<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!]