Skip to content

Commit

Permalink
Adding reform - using OpenStruct for now. It's not performant, but ne…
Browse files Browse the repository at this point in the history
…w/edit are low stakes, and makes for ez flexibility with the json response. Should likely move the casting to atlas_rb, but will hold off until the ergonomics feel right
  • Loading branch information
dgcliff committed Jan 4, 2024
1 parent 3f93dcf commit 7a39b14
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.25
2.3.26
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ gem 'libreconv'
gem 'mods'
gem 'noid-rails', git: 'https://github.com/dgcliff/noid-rails.git', branch: 'rails-7-trial'
gem 'pg'
gem 'reform-rails'
gem 'rsolr', '>= 1.0', '< 3'
gem 'ruby-filemagic'
gem 'sassc-rails', '~> 2.1'
Expand Down
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ GEM
debug (1.6.3)
irb (>= 1.3.6)
reline (>= 0.3.1)
declarative (0.0.20)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -137,6 +138,9 @@ GEM
devise-i18n (1.10.2)
devise (>= 4.8.0)
diff-lcs (1.5.0)
disposable (0.6.3)
declarative (>= 0.0.9, < 1.0.0)
representable (>= 3.1.1, < 4)
docile (1.4.0)
edtf (3.1.0)
activesupport (>= 3.0, < 8.0)
Expand Down Expand Up @@ -273,9 +277,20 @@ GEM
rake (13.0.6)
redis-client (0.17.0)
connection_pool
reform (2.6.2)
disposable (>= 0.5.0, < 1.0.0)
representable (>= 3.1.1, < 4)
uber (< 0.2.0)
reform-rails (0.2.6)
activemodel (>= 5.0)
reform (>= 2.3.1, < 3.0.0)
regexp_parser (2.6.0)
reline (0.3.1)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
Expand Down Expand Up @@ -365,12 +380,14 @@ GEM
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.0)
trailblazer-option (0.1.2)
turbo-rails (1.3.2)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.3.0)
view_component (2.82.0)
activesupport (>= 5.2.0, < 8.0)
Expand Down Expand Up @@ -419,6 +436,7 @@ DEPENDENCIES
puma (~> 5.6)
rails (~> 7.0.1)
rails-controller-testing
reform-rails
rsolr (>= 1.0, < 3)
rspec
rspec-rails
Expand Down
1 change: 1 addition & 0 deletions app/controllers/communities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def new
def edit
# TODO: need to do admin check
# @resource = CommunityChangeSet.new(Community.find(params[:id]).decorate)
@resource = CommunityForm.new(OpenStruct.new(AtlasRb::Community.find(params[:id])))
end

def create
Expand Down
5 changes: 5 additions & 0 deletions app/models/community_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class CommunityForm < Reform::Form
property :title
property :description
validates :title, presence: true
end
2 changes: 1 addition & 1 deletion app/views/communities/_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= simple_form_for @resource do |f|
= f.input :title
= f.input :description
= f.input :description, as: :text, :input_html => { 'rows' => 10 }
= f.button :submit, class: "btn btn-primary my-3"

0 comments on commit 7a39b14

Please sign in to comment.