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
marenz has quit [Ping timeout: 256 seconds]
<FromGitter> <TsumiNa> @robacarp There is my `application.cr` file. https://gist.github.com/TsumiNa/09043cadbee38bfc772cab4e7eb3f44f
<FromGitter> <sclee15> Does anybody use Scry for an amber app?
<FromGitter> <kolyaio> @robacarp the question isn’t wether I can generate those but I what would be right way to separate things that belong to the admin and leave on the site itself only things that related to normal users. ⏎ ⏎ Btw how I make roles in the system ? 😮
marenz has joined #amber
<FromGitter> <kolyaio> I want to render view from the path /views/admin/posts but amber trying to import from admin_posts how can override that?
feepbot has quit [Ping timeout: 240 seconds]
feepbot has joined #amber
<hightower5> kolyao in your call to render, you can put specific path
<hightower5> See https://github.com/crystallabs/amber-introduction for more info on that and other practical stuff with Amber
<FromGitter> <kolyaio> @hightower5 ⏎ ⏎ So in each method I need to add the path /admin/post/something.ecr ? ⏎ ⏎ I thought maybe I can announce in my main AdminController and every class that inherits it automatically render itself add the “admin” thing no? [https://gitter.im/amberframework/amber?at=5b6d764d179f842c971b5703]
<hightower5> kolyaio: yes, I believe you have to specify it. When you call render() this is actually a macro and it is defined in Amber in the file src/amber/controller/helpers/render.cr. If you open it, you will see that you can pre-set the value for LAYOUT, but not for where views will be looked up
<hightower5> What you can do is write a minimal function which you call instead of providing filename literally
<hightower5> Like, you can do render( my( "file")), and you can define my() in your application_controller.cr. That way it will be accessible in all controllers
<hightower5> And you can make it return the path you want, for example (maybe not 100% working, but you get the idea): def my(file) return File.join SUBDIR, file end
<hightower5> And in your controller you set SUBDIR = /views/admin/posts or whatever
<hightower5> Alternatively, you can even override render() so that it does this, so you don't need a separate function
<FromGitter> <kolyaio> @hightower5 yeah you are right I probably expected to much magic 😔
<FromGitter> <kolyaio> How can specify that my My controller is located in /controllers/Admin to the router?
<FromGitter> <kolyaio> I tried `resources "/posts", “Admin/AdminPostsControlle”
<FromGitter> <kolyaio> And even `resources "/posts", “/Admin/” + AdminPostsController
<FromGitter> <kolyaio> And `resources "/posts", :Admin + AdminPostsController`
<hightower5> kolyaio: when you specify controller in the router configuration, you use the class name there, not file path
<hightower5> That means two things:
<hightower5> 1) You need to "require" this controller file from your config/application.cr (if it is not located where amber would load it automatically -- see the line require "../src/controllers/**" in that file)
<FromGitter> <kolyaio> Oh
<hightower5> and 2) if your controller class name is e.g. Admin::AdminPostsController, then you simply add a line like "get "/", Admin::AdminPostsController, :index" to your config/routes.cr and that's it
<hightower5> (or 'resources /posts' or whatever, that "get "/"" was just a default example)
<FromGitter> <kolyaio> Thank you really helped, I try to use the docs but there are a lot of stuff that just not there :-D
<hightower5> No worries, any time
vivus has joined #amber
hightower5 has quit [Remote host closed the connection]
marenz has quit [Ping timeout: 240 seconds]