【 Ruby on Rails】Hướng dẫn sử dụng ActionText
Cài đặt ActionTextrails action_text:installrake db:migrate
Không cần phải có column "content" trong table articlesapp/models/article.rbhas_rich_text :content
validates :content, presence: true, length: { minimum: 5 }
app/controllers/articles_controller.rbdef article_params
params.require(:article).permit(:content)
end
app/views/articles/_form.html.slim= f.label :content
= f.rich_text_area :content
app/views/articles/show.html.slim== @article.contentCustomize...
Updated at 2023-05-09
【Ruby on Rails】Hướng dẫn làm chức năng sort với jquery-ui sortable
Cài đặt jQuery và jQuery-ui
yarn add popper.js jquery jquery-ui
```javascript:config/webpack/environment.js
const { environment } = require('@rails/webpacker')
// Add
const webpack = require('webpack')
environment.plugins.append(
'Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Popper: ['popper.js', 'default']
})
)
// Add
module.exports =...
Updated at 2023-05-09