Documentation for views
Love FAE.
Its missing some documentation on the views though. It demonstrates how to call a page with .instance but retrieving something like articles, it lacks the documentation for it.
My controller:
class ArticlesController < Fae::BaseController
layout :set_layout
def index
@articles = Article.all
end
#
def show
@article = Article.find(params[:id])
end
private
def build_assets
@item.build_hero_image if @item.hero_image.blank?
@item.build_pdf if @item.pdf.blank?
end
def set_layout
'frontend'
end
def set_article
@article = Article.find(params[:id])
end
def article_params
params.require(:article).permit(:title )
end
end
and for Article show.slim.html:
- @article.fae_display_field
Am I missing something?
I was able to get the index view with the example code for @items:
- if @articles.present?
- @articles.each do |article|
tr id=fae_sort_id(article)
td = link_to article.fae_display_field, article_path(article)
td = fae_date_format article.updated_at
- else
tr: td colspan="3" No items found
Hi @Austex, so glad you love Fae!
fae_display_field is an overridable method for use inside your admin area only.
See Docs: https://www.faecms.com/documentation/topics-models
I see you have your show action inside the Fae controller. If I am understanding your question correctly, I believe you are trying to use @articles on the front end outside of Fae. You should only keep admin related items there, and for your views, code everything as you normally do in Rails.
I.E. create an articles_controller.rb outside the admin scope and set up your show action there. Then you can call @article.something on your show.html.slim, and be sure not to use the Fae DSL outside of the admin.
Please see issues #226 and #218 (comment), as I believe they are similar to what you are asking.
Hope this helps!