Class: FactorySeeder::CustomSeedsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FactorySeeder::CustomSeedsController
- Defined in:
- app/controllers/factory_seeder/custom_seeds_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 29 def create seed_name = params[:name] seed = FactorySeeder.find_custom_seed(seed_name) if seed.nil? flash[:error] = "Seed '#{seed_name}' not found" redirect_to custom_seeds_path return end attributes = safe_attributes_params result = FactorySeeder.run_custom_seed(seed_name, **attributes) logs = result[:logs] || [] flash_type = result[:success] ? :success : :error log_id = ExecutionLogStore.store(logs, flash_type: flash_type, flash_message: result[:message]) redirect_to custom_seed_path(seed_name, log_id: log_id) end |
#destroy ⇒ Object
70 71 72 73 74 75 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 70 def destroy # For deleting seeds (future feature) params[:name] # Implementation would go here redirect_to custom_seeds_path end |
#edit ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 54 def edit @seed = FactorySeeder.find_custom_seed(params[:name]) return unless @seed.nil? flash[:error] = "Seed '#{params[:name]}' not found" redirect_to custom_seeds_path nil end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 5 def index @seeds = FactorySeeder.list_custom_seeds end |
#new ⇒ Object
49 50 51 52 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 49 def new # For creating new seeds via web interface (future feature) @seed = nil end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 9 def show @seed = FactorySeeder.find_custom_seed(params[:name]) if @seed.nil? flash[:error] = "Seed '#{params[:name]}' not found" redirect_to custom_seeds_path return end @seed_name = @seed.name @execution_logs = [] # Retrieve logs from temporary storage if available (PRG pattern) if params[:log_id].present? stored = ExecutionLogStore.retrieve(params[:log_id]) if stored @execution_logs = stored[:logs] || [] flash.now[stored[:flash_type]] = stored[:flash_message] if stored[:flash_type] end end end |
#update ⇒ Object
63 64 65 66 67 68 |
# File 'app/controllers/factory_seeder/custom_seeds_controller.rb', line 63 def update # For updating existing seeds (future feature) seed_name = params[:name] # Implementation would go here redirect_to custom_seed_path(seed_name) end |