plutonium 0.15.8 → 0.15.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -81
- data/docs/.vitepress/config.ts +3 -1
- data/docs/guide/getting-started/index.md +4 -1
- data/docs/guide/tutorial.md +403 -0
- data/docs/index.md +19 -15
- data/docs/public/tutorial/plutonium-association-panel.png +0 -0
- data/docs/public/tutorial/plutonium-dashboard.png +0 -0
- data/docs/public/tutorial/plutonium-login-page.png +0 -0
- data/docs/public/tutorial/plutonium-nested-form.png +0 -0
- data/docs/public/tutorial/plutonium-posts-dashboard-customized.png +0 -0
- data/docs/public/tutorial/plutonium-posts-dashboard.png +0 -0
- data/docs/public/tutorial/plutonium-posts-detail-customized.png +0 -0
- data/docs/public/tutorial/plutonium-posts-detail.png +0 -0
- data/docs/public/tutorial/plutonium-publish-post.png +0 -0
- data/lib/generators/pu/gem/standard/standard_generator.rb +1 -1
- data/lib/plutonium/core/controllers/bootable.rb +3 -3
- data/lib/plutonium/resource/controller.rb +2 -2
- data/lib/plutonium/resource/register.rb +3 -3
- data/lib/plutonium/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09172a90865acf0fb8b929464cd3314470ad63ec7bc9dbfd2a5e132f1147ed3a'
|
4
|
+
data.tar.gz: a652d15c85664a3ad4ae371988b19cc8a3a3846500d53e1b8ebe21ca0e82c77b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b04ba22b0c86f7de0e2319f9a984e3d9adc4d35b15f2bfaa227b6525a1e1912627badfa09bbb4c6726d2adc7fae29c6287912056bc5844d5a28ce273e0a07a0d
|
7
|
+
data.tar.gz: 85d376dfe9514b215bfad51a7bf848a543bd37f6afb4af971b2c9da4d69ea8a4075dfec62dafad39f571b03e782348dd90287bb82d5389b6781ddc13509d8d4b
|
data/README.md
CHANGED
@@ -1,95 +1,33 @@
|
|
1
|
-
# Plutonium:
|
1
|
+
# Plutonium: It's like Rails, but for Rails!
|
2
2
|
|
3
3
|
[![Ruby](https://github.com/radioactive-labs/plutonium-core/actions/workflows/main.yml/badge.svg)](https://github.com/radioactive-labs/plutonium-core/actions/workflows/main.yml)
|
4
4
|
|
5
|
-
|
5
|
+
**Plutonium** is a powerful Rapid Application Development (RAD) toolkit for Rails that picks up where Rails left off, introducing application-level concepts and tooling that transform the way you build applications.
|
6
6
|
|
7
|
-
|
7
|
+
## Overview
|
8
8
|
|
9
|
-
|
10
|
-
It's a culmination of lessons learned from years of developing nearly identical applications and is designed to save you from the drudgery of re-implementation.
|
9
|
+
Plutonium builds upon Rails' conventions and extends them with:
|
11
10
|
|
12
|
-
**
|
11
|
+
- **Authentication & Authorization**: Integrates seamlessly with Rodauth or your existing auth system
|
12
|
+
- **Complete CRUD Operations**: Rich fields, forms, tables, and nested resources out of the box
|
13
|
+
- **Modular Architecture**: Package system based on Rails engines for better organization
|
14
|
+
- **Entity Scoping**: Built-in multi-tenancy support that "just works"
|
15
|
+
- **Smart Generators**: Eliminate boilerplate while maintaining flexibility
|
16
|
+
- **Modern UI**: Beautiful, responsive interface powered by Tailwind CSS and Hotwire
|
13
17
|
|
14
|
-
|
15
|
-
- **Comprehensive Features:** Plutonium covers a wide array of functionalities out of the box:
|
16
|
-
- Authentication & Authorization
|
17
|
-
- Complete CRUD operations with advanced features: customizable inputs, fields, tables, forms, pagination, actions, search, scopes, filtering, nested resources and much more.
|
18
|
-
- Modular architecture leveraging Rails engines for improved packaging and namespacing.
|
19
|
-
- Time-saving generators for boilerplate tasks.
|
20
|
-
- **Omakase with a Twist:** Inspired by Rails' omakase philosophy, Plutonium delivers a convention-based approach but doesn't box you in. It's seamlessly integrated into your project, allowing you to write your application as you would with vanilla Rails but with powerful extensions.
|
21
|
-
- **MVC and Beyond:** Plutonium adopts the MVC pattern, enhanced with modern web technologies like [hotwire](TODO), to deliver an interactive and robust user experience. It emphasizes progressive enhancement, ensuring a smooth development process and end-user experience.
|
22
|
-
- **Rails Harmony:** A Plutonium app is a Rails app at its core. It respects and builds upon Rails' conventions, making it intuitive for Rails developers. If you know Rails, learning Plutonium requires only a few new concepts.
|
23
|
-
- **Effortless Customization:** Plutonium is designed for easy customization to meet your unique requirements. Whether adjusting the functionality of entire resource groups or fine-tuning individual elements, our accessible low-level APIs and the familiar Rails conventions offer unparalleled flexibility. This ensures that any modifications you need to make can be implemented swiftly and smoothly, reducing complexity and enhancing your development experience.
|
24
|
-
- **Community-Driven Dependencies:** Plutonium stands on the shoulders of giants, integrating with well-established gems chosen for their robustness and flexibility, including:
|
25
|
-
- [ActiveInteraction](https://github.com/AaronLasseigne/active_interaction) for business logic
|
26
|
-
- [Pagy](https://github.com/ddnexus/pagy) for pagination
|
27
|
-
- [Action Policy](https://actionpolicy.evilmartians.io/): for authorization
|
28
|
-
- [Simple Form](https://github.com/heartcombo/simple_form) for forms
|
29
|
-
- [Rodauth](https://github.com/jeremyevans/rodauth) (via [rodauth-rails](https://github.com/janko/rodauth-rails)) for authentication. Rodauth is optional, allowing flexibility in choosing your auth solution
|
18
|
+
## Project Status
|
30
19
|
|
31
|
-
|
20
|
+
> [!WARNING]
|
21
|
+
> While Plutonium is actively used in production environments, it's still in early development. APIs may change, and some features are still evolving. We recommend thoroughly testing before deploying to production.
|
32
22
|
|
33
|
-
|
23
|
+
## Documentation
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
2. **Bundle Install:**
|
42
|
-
|
43
|
-
```shell
|
44
|
-
bundle
|
45
|
-
```
|
46
|
-
|
47
|
-
3. **Install Plutonium:**
|
48
|
-
|
49
|
-
```shell
|
50
|
-
rails g pu:core:install
|
51
|
-
```
|
52
|
-
|
53
|
-
Start building your Rails applications faster, with more flexibility and less boilerplate. **Plutonium** is here to revolutionize your development process.
|
54
|
-
|
55
|
-
## Usage
|
56
|
-
|
57
|
-
TODO: Write usage instructions here
|
58
|
-
|
59
|
-
## Development
|
60
|
-
|
61
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
|
-
|
63
|
-
To build assets, run `npm dev`
|
64
|
-
|
65
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
66
|
-
|
67
|
-
## Contributing
|
68
|
-
|
69
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/plutonium.
|
25
|
+
Visit our [documentation](https://radioactive-labs.github.io/plutonium-core/) for:
|
26
|
+
- Getting started guide
|
27
|
+
- Installation instructions
|
28
|
+
- Core concepts
|
29
|
+
- Tutorials
|
70
30
|
|
71
31
|
## License
|
72
32
|
|
73
33
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
74
|
-
|
75
|
-
<!--
|
76
|
-
# ------------------------------
|
77
|
-
|
78
|
-
gem "plutonium", path: "/Users/stefan/code/plutonium/starters/plutonium/"
|
79
|
-
gem "plutonium_generators", github: "radioactive-labs/plutonium-generators", group: [:development, :test]
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# rails new vulcan \
|
84
|
-
# --skip-action-mailbox --skip-action-text --skip-active-storage --skip-action-cable --skip-jbuilder \
|
85
|
-
# --skip-test --skip-system-test --javascript=esbuild --css=bootstrap --database=postgresql
|
86
|
-
|
87
|
-
|
88
|
-
```bash
|
89
|
-
rails new pluton8_starter --name="Pluton8 Starter" --database=sqlite3 --skip-action-mailbox --skip-action-text --skip-active-storage --asset-pipeline=propshaft --skip-jbuilder --javascript=importmap --css=tailwind
|
90
|
-
|
91
|
-
bin/rails app:template LOCATION=/Users/stefan/code/plutonium/starters/vulcan/gems/plutonium/templates/base.rb
|
92
|
-
```
|
93
|
-
|
94
|
-
rails g pu:rodauth:account admin --no-defaults --login --logout --remember --change-password --internal-request --create-account --lockout --verify-account --audit-logging --close-account --otp --reset-password --reset-password-notify --active-sessions --recovery-codes --password-grace-period
|
95
|
-
-->
|
data/docs/.vitepress/config.ts
CHANGED
@@ -17,7 +17,8 @@ export default defineConfig(withMermaid({
|
|
17
17
|
},
|
18
18
|
nav: [
|
19
19
|
{ text: "Home", link: "/" },
|
20
|
-
{ text: "Guide", link: "/guide/getting-started" }
|
20
|
+
{ text: "Guide", link: "/guide/getting-started" },
|
21
|
+
{ text: "Demo", link: "https://plutonium-app.onrender.com/" }
|
21
22
|
],
|
22
23
|
sidebar: {
|
23
24
|
'/guide/': [
|
@@ -26,6 +27,7 @@ export default defineConfig(withMermaid({
|
|
26
27
|
text: "Introduction",
|
27
28
|
items: [
|
28
29
|
{ text: "What is Plutonium?", link: "/guide/what-is-plutonium" },
|
30
|
+
{ text: "Tutorial", link: "/guide/tutorial" },
|
29
31
|
]
|
30
32
|
},
|
31
33
|
{
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# Getting Started with Plutonium
|
2
2
|
|
3
3
|
<!--
|
4
|
-
This guide covers getting up and running with Plutonium.
|
5
4
|
|
6
5
|
After reading this guide, you will know:
|
7
6
|
|
@@ -10,6 +9,10 @@ After reading this guide, you will know:
|
|
10
9
|
- The basic principles of Resource design.
|
11
10
|
- How to quickly generate the starting pieces of a Plutonium application.
|
12
11
|
-->
|
12
|
+
This guide covers getting up and running with Plutonium.
|
13
|
+
It is intended to be a more detailed guide.
|
14
|
+
|
15
|
+
If you're interested in a quick start, check out our [tutorial](/guide/tutorial).
|
13
16
|
|
14
17
|
## Prerequisites
|
15
18
|
|
@@ -0,0 +1,403 @@
|
|
1
|
+
# Building a Blog with Plutonium
|
2
|
+
|
3
|
+
# Building a Blog with Plutonium
|
4
|
+
|
5
|
+
> **Quick Links:**
|
6
|
+
> - 🔍 [Tutorial Demo](https://github.com/radioactive-labs/plutonium-app)
|
7
|
+
> - 📂 [Tutorial Source Code](https://github.com/radioactive-labs/plutonium-app)
|
8
|
+
|
9
|
+
This tutorial walks through building a blog application using Plutonium. You'll learn how to:
|
10
|
+
|
11
|
+
- Set up authentication using Rodauth
|
12
|
+
- Create a blog feature package
|
13
|
+
- Build a dashboard/portal
|
14
|
+
- Implement posts and comments
|
15
|
+
- Add interactive actions
|
16
|
+
- Configure scoping and authorization
|
17
|
+
|
18
|
+
[Rest of the tutorial content remains exactly the same...]
|
19
|
+
|
20
|
+
## Initial Setup
|
21
|
+
|
22
|
+
Let's start by creating a new Rails application with Plutonium:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
rails new plutonium_app -a propshaft -j esbuild -c tailwind \
|
26
|
+
-m https://radioactive-labs.github.io/plutonium-core/templates/plutonium.rb
|
27
|
+
```
|
28
|
+
|
29
|
+
This creates a new Rails application with:
|
30
|
+
- Propshaft as the asset pipeline
|
31
|
+
- esbuild for JavaScript bundling
|
32
|
+
- Tailwind CSS for styling
|
33
|
+
- Plutonium's base configuration
|
34
|
+
|
35
|
+
## Setting Up Authentication
|
36
|
+
|
37
|
+
Next, let's add authentication using Rodauth:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
# Generate Rodauth configuration
|
41
|
+
rails generate pu:rodauth:install
|
42
|
+
|
43
|
+
# Generate user account setup
|
44
|
+
rails generate pu:rodauth:account user
|
45
|
+
rails db:migrate
|
46
|
+
```
|
47
|
+
|
48
|
+
This sets up:
|
49
|
+
- A User model with authentication
|
50
|
+
- Login/logout functionality
|
51
|
+
- Account verification via email
|
52
|
+
- Password reset capabilities
|
53
|
+
|
54
|
+
![Plutonium Login Page](/tutorial/plutonium-login-page.png)
|
55
|
+
|
56
|
+
The key files created include:
|
57
|
+
- `app/models/user.rb` - The User model
|
58
|
+
- `app/rodauth/user_rodauth_plugin.rb` - Rodauth configuration
|
59
|
+
- `app/controllers/rodauth_controller.rb` - Base controller for auth pages
|
60
|
+
- Database migrations for users and auth-related tables
|
61
|
+
|
62
|
+
## Creating the Blog Feature Package
|
63
|
+
|
64
|
+
Let's create a dedicated package for our blogging functionality:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
rails generate pu:pkg:package blogging
|
68
|
+
```
|
69
|
+
|
70
|
+
This generates a new feature package under `packages/blogging/` with:
|
71
|
+
- Base controllers
|
72
|
+
- Model and policy base classes
|
73
|
+
- Package-specific views directory
|
74
|
+
- Engine configuration
|
75
|
+
|
76
|
+
## Adding Posts Resource
|
77
|
+
|
78
|
+
Now we can add our first resource - blog posts:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
rails generate pu:res:scaffold post user:belongs_to title:string \
|
82
|
+
content:text 'published_at:datetime?'
|
83
|
+
```
|
84
|
+
|
85
|
+
::: tip
|
86
|
+
Unlike Rails, Plutonium generates fields as non-null by default.
|
87
|
+
Appending `?` to the type e.g. `published_at:datetime?` makes `published_at` a **nullable** datetime.
|
88
|
+
:::
|
89
|
+
|
90
|
+
When prompted, select the `blogging` feature package.
|
91
|
+
|
92
|
+
This creates:
|
93
|
+
- Post model with associations
|
94
|
+
- Policy class with basic permissions
|
95
|
+
- Controllers for CRUD operations
|
96
|
+
- Database migration
|
97
|
+
|
98
|
+
The generated post model includes:
|
99
|
+
```ruby
|
100
|
+
class Blogging::Post < Blogging::ResourceRecord
|
101
|
+
belongs_to :user
|
102
|
+
validates :title, presence: true
|
103
|
+
validates :content, presence: true
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
Remember to apply the new migrations:
|
108
|
+
```bash
|
109
|
+
rails db:migrate
|
110
|
+
```
|
111
|
+
|
112
|
+
## Creating the Dashboard Portal
|
113
|
+
|
114
|
+
Let's add a portal to manage our blog:
|
115
|
+
|
116
|
+
```bash
|
117
|
+
rails generate pu:pkg:portal dashboard
|
118
|
+
```
|
119
|
+
|
120
|
+
When prompted, select `user` for authentication.
|
121
|
+
|
122
|
+
This creates a new portal package under `packages/dashboard_portal/` with:
|
123
|
+
- Portal-specific controllers
|
124
|
+
- Resource presentation layer
|
125
|
+
- Dashboard views
|
126
|
+
- Authenticated routes
|
127
|
+
|
128
|
+
## Configure Routes
|
129
|
+
|
130
|
+
Let's configure our application routes to properly handle authentication and dashboard access:
|
131
|
+
|
132
|
+
::: code-group
|
133
|
+
```ruby [app/rodauth/user_rodauth_plugin.rb]
|
134
|
+
# ==> Redirects
|
135
|
+
|
136
|
+
# Redirect to home after login.
|
137
|
+
create_account_redirect "/" # [!code --]
|
138
|
+
create_account_redirect "/dashboard" # [!code ++]
|
139
|
+
|
140
|
+
# Redirect to home after login.
|
141
|
+
login_redirect "/" # [!code --]
|
142
|
+
login_redirect "/dashboard" # [!code ++]
|
143
|
+
|
144
|
+
# Redirect to home page after logout.
|
145
|
+
logout_redirect "/" # [!code --]
|
146
|
+
logout_redirect "/dashboard" # [!code ++]
|
147
|
+
|
148
|
+
# Redirect to wherever login redirects to after account verification.
|
149
|
+
verify_account_redirect { login_redirect }
|
150
|
+
```
|
151
|
+
|
152
|
+
```ruby [config/routes.rb]
|
153
|
+
Rails.application.routes.draw do
|
154
|
+
# Other routes...
|
155
|
+
|
156
|
+
# Defines the root path route ("/")
|
157
|
+
# root "posts#index" # [!code --]
|
158
|
+
root to: redirect("/dashboard") # [!code ++]
|
159
|
+
end
|
160
|
+
```
|
161
|
+
:::
|
162
|
+
|
163
|
+
These changes ensure that:
|
164
|
+
- Users are directed to the dashboard after signing up
|
165
|
+
- Users are directed to the dashboard after logging in
|
166
|
+
- Users are directed to the dashboard after logging out
|
167
|
+
- The root URL (`/`) redirects to the dashboard
|
168
|
+
- Account verification follows the same flow as login
|
169
|
+
|
170
|
+
## Connecting Posts to Dashboard
|
171
|
+
|
172
|
+
We can now connect our blog posts to the dashboard:
|
173
|
+
|
174
|
+
```bash
|
175
|
+
rails generate pu:res:conn
|
176
|
+
```
|
177
|
+
|
178
|
+
Select:
|
179
|
+
1. Source feature: `blogging`
|
180
|
+
2. Resources: `Blogging::Post`
|
181
|
+
3. Portal: `dashboard_portal`
|
182
|
+
|
183
|
+
This configures the routing and controllers to display posts in the dashboard.
|
184
|
+
|
185
|
+
![Plutonium Posts Dashboard](/tutorial/plutonium-posts-dashboard.png)
|
186
|
+
|
187
|
+
## Adding Comments
|
188
|
+
|
189
|
+
Let's add commenting functionality:
|
190
|
+
|
191
|
+
```bash
|
192
|
+
rails generate pu:res:scaffold comment blogging/post:belongs_to \
|
193
|
+
user:belongs_to body:text
|
194
|
+
|
195
|
+
rails db:migrate
|
196
|
+
|
197
|
+
rails generate pu:res:conn
|
198
|
+
```
|
199
|
+
|
200
|
+
::: tip
|
201
|
+
Note the use of the namespaced model in the association `blogging/post`.
|
202
|
+
|
203
|
+
Plutonium has inbuilt support for handling namespaces, generating:
|
204
|
+
```ruby
|
205
|
+
# model
|
206
|
+
belongs_to :post, class_name: "Blogging::Post"
|
207
|
+
|
208
|
+
# migration
|
209
|
+
t.belongs_to :post, null: false, foreign_key: {:to_table=>:blogging_posts}
|
210
|
+
```
|
211
|
+
:::
|
212
|
+
|
213
|
+
This creates:
|
214
|
+
- Comment model with associations
|
215
|
+
- Policy controlling access
|
216
|
+
- CRUD interface in dashboard
|
217
|
+
- Proper routing configuration
|
218
|
+
|
219
|
+
## Customizing the Interface
|
220
|
+
|
221
|
+
### Post Table Customization
|
222
|
+
|
223
|
+
We can customize how posts appear in the table view:
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
# packages/blogging/app/policies/blogging/post_policy.rb
|
227
|
+
def permitted_attributes_for_index
|
228
|
+
[:user, :title, :published_at, :created_at]
|
229
|
+
end
|
230
|
+
```
|
231
|
+
|
232
|
+
![Plutonium Posts Dashboard (Customized)](/tutorial/plutonium-posts-dashboard-customized.png)
|
233
|
+
|
234
|
+
### Post Detail View
|
235
|
+
|
236
|
+
Customize the post detail layout using display grids:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
# packages/blogging/app/definitions/blogging/post_definition.rb
|
240
|
+
class Blogging::PostDefinition < Blogging::ResourceDefinition
|
241
|
+
display :user, class: "col-span-full"
|
242
|
+
display :title, class: "col-span-full"
|
243
|
+
display :content, class: "col-span-full"
|
244
|
+
display :published_at, class: "col-span-full"
|
245
|
+
end
|
246
|
+
```
|
247
|
+
|
248
|
+
![Plutonium Posts Detail (Customized)](/tutorial/plutonium-posts-detail-customized.png)
|
249
|
+
|
250
|
+
## Adding Publishing Functionality
|
251
|
+
|
252
|
+
Let's add the ability to publish posts:
|
253
|
+
|
254
|
+
::: code-group
|
255
|
+
|
256
|
+
```ruby [post_definition.rb]
|
257
|
+
# packages/blogging/app/definitions/blogging/post_definition.rb
|
258
|
+
action :publish,
|
259
|
+
interaction: Blogging::Posts::Publish,
|
260
|
+
collection_record_action: false # do not show this on the table
|
261
|
+
```
|
262
|
+
|
263
|
+
```ruby [publish.rb]
|
264
|
+
# packages/blogging/app/interactions/blogging/posts/publish.rb
|
265
|
+
module Blogging
|
266
|
+
module Posts
|
267
|
+
class Publish < ResourceInteraction
|
268
|
+
presents label: "Publish Post", icon: Phlex::TablerIcons::Send
|
269
|
+
attribute :resource
|
270
|
+
|
271
|
+
def execute
|
272
|
+
if resource.update(published_at: Time.current)
|
273
|
+
succeed(resource)
|
274
|
+
.with_message("Post was successfully published")
|
275
|
+
else
|
276
|
+
failed(resource.errors)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
```
|
283
|
+
|
284
|
+
```ruby [post_policy.rb]
|
285
|
+
# packages/blogging/app/policies/blogging/post_policy.rb
|
286
|
+
|
287
|
+
def publish? # [!code ++]
|
288
|
+
!record.published_at # [!code ++]
|
289
|
+
end # [!code ++]
|
290
|
+
|
291
|
+
|
292
|
+
def permitted_attributes_for_create
|
293
|
+
[:user, :title, :content, :published_at] # [!code --]
|
294
|
+
[:user, :title, :content] # [!code ++]
|
295
|
+
end
|
296
|
+
```
|
297
|
+
|
298
|
+
:::
|
299
|
+
|
300
|
+
![Plutonium Publish Post](/tutorial/plutonium-publish-post.png)
|
301
|
+
|
302
|
+
## Adding Comments Panel
|
303
|
+
|
304
|
+
Enable viewing comments on posts:
|
305
|
+
|
306
|
+
::: code-group
|
307
|
+
|
308
|
+
```ruby [post.rb]
|
309
|
+
# packages/blogging/app/models/blogging/post.rb
|
310
|
+
has_many :comments
|
311
|
+
```
|
312
|
+
|
313
|
+
```ruby [post_policy.rb]
|
314
|
+
# packages/blogging/app/policies/blogging/post_policy.rb
|
315
|
+
def permitted_associations
|
316
|
+
%i[comments]
|
317
|
+
end
|
318
|
+
```
|
319
|
+
|
320
|
+
:::
|
321
|
+
|
322
|
+
![Plutonium Comments Panel](/tutorial/plutonium-association-panel.png)
|
323
|
+
|
324
|
+
## Scoping Resources
|
325
|
+
|
326
|
+
Ensure users only see their own content:
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
# packages/dashboard_portal/lib/engine.rb
|
330
|
+
module DashboardPortal
|
331
|
+
class Engine < Rails::Engine
|
332
|
+
include Plutonium::Portal::Engine
|
333
|
+
|
334
|
+
config.after_initialize do
|
335
|
+
scope_to_entity User, strategy: :current_user
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
```
|
340
|
+
|
341
|
+
## Adding Nested Comments
|
342
|
+
|
343
|
+
Enable adding comments directly from the post form:
|
344
|
+
|
345
|
+
::: code-group
|
346
|
+
|
347
|
+
```ruby [post_definition.rb]
|
348
|
+
# packages/blogging/app/definitions/blogging/post_definition.rb
|
349
|
+
nested_input :comments,
|
350
|
+
using: Blogging::CommentDefinition,
|
351
|
+
fields: %i[user body]
|
352
|
+
```
|
353
|
+
|
354
|
+
```ruby [post.rb]
|
355
|
+
# packages/blogging/app/models/blogging/post.rb
|
356
|
+
has_many :comments
|
357
|
+
accepts_nested_attributes_for :comments # [!code ++]
|
358
|
+
```
|
359
|
+
|
360
|
+
```ruby [post_policy.rb]
|
361
|
+
# packages/blogging/app/policies/blogging/post_policy.rb
|
362
|
+
def permitted_attributes_for_create
|
363
|
+
[:user, :title, :content] # [!code --]
|
364
|
+
[:user, :title, :content, :comments] # [!code ++]
|
365
|
+
end
|
366
|
+
```
|
367
|
+
|
368
|
+
:::
|
369
|
+
|
370
|
+
![Plutonium Nested Comments](/tutorial/plutonium-nested-form.png)
|
371
|
+
|
372
|
+
## Running the Application
|
373
|
+
|
374
|
+
1. Start the Development server:
|
375
|
+
```bash
|
376
|
+
bin/dev
|
377
|
+
```
|
378
|
+
|
379
|
+
2. Visit `http://localhost:3000`
|
380
|
+
|
381
|
+
3. Create a user account and start managing your blog!
|
382
|
+
|
383
|
+
## What's Next?
|
384
|
+
|
385
|
+
Some ideas for extending the application:
|
386
|
+
- Add categories/tags for posts
|
387
|
+
- Implement comment moderation
|
388
|
+
- Add rich text editing for post content
|
389
|
+
- Create a public-facing blog view
|
390
|
+
- Add image attachments for posts
|
391
|
+
- Implement social sharing
|
392
|
+
|
393
|
+
## Conclusion
|
394
|
+
|
395
|
+
In this tutorial, we've built a full-featured blog application with:
|
396
|
+
- User authentication
|
397
|
+
- Post management
|
398
|
+
- Commenting system
|
399
|
+
- Publishing workflow
|
400
|
+
- Proper authorization
|
401
|
+
- User-scoped content
|
402
|
+
|
403
|
+
Plutonium helped us quickly scaffold and connect the pieces while maintaining clean separation of concerns through its package system.
|
data/docs/index.md
CHANGED
@@ -17,27 +17,31 @@ hero:
|
|
17
17
|
link: /guide/what-is-plutonium
|
18
18
|
|
19
19
|
features:
|
20
|
-
|
21
|
-
|
20
|
+
# Core Value Proposition - Start with the main benefit
|
21
|
+
- title: Rich Resource Management
|
22
|
+
details: Beautiful, modern interfaces with production-ready components for rapid development
|
22
23
|
|
23
|
-
-
|
24
|
-
|
24
|
+
# Core Architecture Features - Foundation pieces
|
25
|
+
- title: Built-in Multitenancy
|
26
|
+
details: Row-level multitenancy that works out of the box - perfect for SaaS and enterprise apps
|
25
27
|
|
26
|
-
- title:
|
27
|
-
details:
|
28
|
+
- title: Advanced Authorization
|
29
|
+
details: Comprehensive access control built on Action Policy's proven authorization framework
|
28
30
|
|
29
|
-
- title:
|
30
|
-
details:
|
31
|
+
- title: Seamless Authentication
|
32
|
+
details: Integrate your existing auth or use our Rodauth integration - ready in seconds
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
# Developer Experience Features - How it makes development easier
|
35
|
+
- title: Intelligent Fields
|
36
|
+
details: Smart field detection with automatic Rails model mapping and zero configuration needed
|
34
37
|
|
35
38
|
- title: Advanced Nested Resources
|
36
|
-
details: Complex resource relationships made simple
|
39
|
+
details: Complex resource relationships made simple through intelligent relationship mapping
|
37
40
|
|
38
|
-
-
|
39
|
-
|
41
|
+
# Extensibility Features - How it grows with your needs
|
42
|
+
- title: Extensible Workflows
|
43
|
+
details: Add custom actions and business workflows with a simple, declarative API
|
40
44
|
|
41
|
-
- title:
|
42
|
-
details:
|
45
|
+
- title: Flexible UI Customization
|
46
|
+
details: Customize any aspect of your interfaces with elegant builder APIs
|
43
47
|
---
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -21,9 +21,9 @@ module Plutonium
|
|
21
21
|
def inherited(subclass)
|
22
22
|
super
|
23
23
|
|
24
|
-
subclass.include Plutonium::Lib::SmartCache
|
25
|
-
subclass.memoize_unless_reloading :current_package
|
26
|
-
subclass.memoize_unless_reloading :current_engine
|
24
|
+
# subclass.include Plutonium::Lib::SmartCache
|
25
|
+
# subclass.memoize_unless_reloading :current_package
|
26
|
+
# subclass.memoize_unless_reloading :current_engine
|
27
27
|
subclass.boot
|
28
28
|
end
|
29
29
|
|
@@ -23,7 +23,7 @@ module Plutonium
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class_methods do
|
26
|
-
include Plutonium::Lib::SmartCache
|
26
|
+
# include Plutonium::Lib::SmartCache
|
27
27
|
|
28
28
|
# Sets the resource class for the controller
|
29
29
|
# @param [ActiveRecord::Base] resource_class The resource class
|
@@ -40,7 +40,7 @@ module Plutonium
|
|
40
40
|
rescue NameError
|
41
41
|
raise NameError, "Failed to determine the resource class. Please call `controller_for(MyResource)` in #{name}."
|
42
42
|
end
|
43
|
-
memoize_unless_reloading :resource_class
|
43
|
+
# memoize_unless_reloading :resource_class
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -4,7 +4,7 @@ module Plutonium
|
|
4
4
|
module Resource
|
5
5
|
# Resource register manages the registration and lookup of resources.
|
6
6
|
class Register
|
7
|
-
include Plutonium::Lib::SmartCache
|
7
|
+
# include Plutonium::Lib::SmartCache
|
8
8
|
|
9
9
|
# Custom error class for frozen register operations
|
10
10
|
class FrozenRegisterError < StandardError; end
|
@@ -35,7 +35,7 @@ module Plutonium
|
|
35
35
|
freeze
|
36
36
|
@resources.map(&:constantize)
|
37
37
|
end
|
38
|
-
memoize_unless_reloading :resources
|
38
|
+
# memoize_unless_reloading :resources
|
39
39
|
|
40
40
|
# Returns a hash mapping route keys to their corresponding resource classes.
|
41
41
|
# This method will freeze the register if it hasn't been frozen already.
|
@@ -47,7 +47,7 @@ module Plutonium
|
|
47
47
|
[resource.model_name.singular_route_key.to_sym, resource]
|
48
48
|
end
|
49
49
|
end
|
50
|
-
memoize_unless_reloading :route_key_lookup
|
50
|
+
# memoize_unless_reloading :route_key_lookup
|
51
51
|
|
52
52
|
# Clears all registered resources and invalidates the cache.
|
53
53
|
#
|
data/lib/plutonium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -1039,6 +1039,7 @@ files:
|
|
1039
1039
|
- docs/guide/getting-started/index.md
|
1040
1040
|
- docs/guide/getting-started/installation.md
|
1041
1041
|
- docs/guide/getting-started/resources.md
|
1042
|
+
- docs/guide/tutorial.md
|
1042
1043
|
- docs/guide/what-is-plutonium.md
|
1043
1044
|
- docs/index.md
|
1044
1045
|
- docs/markdown-examples.md
|
@@ -1052,6 +1053,15 @@ files:
|
|
1052
1053
|
- docs/public/site.webmanifest
|
1053
1054
|
- docs/public/templates/base.rb
|
1054
1055
|
- docs/public/templates/plutonium.rb
|
1056
|
+
- docs/public/tutorial/plutonium-association-panel.png
|
1057
|
+
- docs/public/tutorial/plutonium-dashboard.png
|
1058
|
+
- docs/public/tutorial/plutonium-login-page.png
|
1059
|
+
- docs/public/tutorial/plutonium-nested-form.png
|
1060
|
+
- docs/public/tutorial/plutonium-posts-dashboard-customized.png
|
1061
|
+
- docs/public/tutorial/plutonium-posts-dashboard.png
|
1062
|
+
- docs/public/tutorial/plutonium-posts-detail-customized.png
|
1063
|
+
- docs/public/tutorial/plutonium-posts-detail.png
|
1064
|
+
- docs/public/tutorial/plutonium-publish-post.png
|
1055
1065
|
- esbuild.config.js
|
1056
1066
|
- exe/pug
|
1057
1067
|
- gemfiles/rails_7.gemfile
|