Skip to content

Commit

Permalink
Merge pull request #27 from tamu-edu-students/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
aketkar18 authored Feb 9, 2023
2 parents dc6109f + b6165c1 commit e8f591b
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 2 deletions.
Empty file removed Untitled
Empty file.
7 changes: 6 additions & 1 deletion app/controllers/experiences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ def update

@experience = Experience.find params[:id]
@experience.update_attributes(:title => params[:experience][:title], :experience => params[:experience][:experience], :rating => params[:experience][:rating], :tags => tagArrayFixed)


# if params[:image]
# @experience.image.purge
# @experience.image.attach(params[:image])
# end

# delete any existing associated location
YelpLocation.where(experience_id: params[:id]).destroy_all

Expand Down
15 changes: 15 additions & 0 deletions app/controllers/programs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ def create
flash[:alert] = 'Cannot create program'
redirect_to programs_path and return
end
<<<<<<< HEAD

@program = Program.create(name: params[:program][:name], location: params[:program][:location],
region: params[:program][:region])
=======

@program = Program.create(:name => params[:program][:name], :location => params[:program][:location], :region => params[:program][:region])

# if params[:banner_image]
# @program.banner_image.attach(params[:banner_image])
# end

>>>>>>> 97f6182a8e92265c160bb0ea2ec44ec7d7332dcc
flash[:notice] = "#{@program.name} was successfully created."
redirect_to programs_path
end
Expand Down Expand Up @@ -84,4 +94,9 @@ def enable
end
redirect_to programs_path
end

def experience_params
params.require(:experience).permit(:name, :location, :region, :banner_image)
end

end
9 changes: 9 additions & 0 deletions app/models/program.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# frozen_string_literal: true

class Program < ApplicationRecord
<<<<<<< HEAD
has_many :users
has_many :tips
has_many :experiences
# has_one :banner_image
end
=======
has_many :users
has_many :tips
has_many :experiences
has_one_attached :banner_image

end
>>>>>>> 97f6182a8e92265c160bb0ea2ec44ec7d7332dcc
6 changes: 5 additions & 1 deletion app/views/experiences/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<td class="experience-edit-label">Experience:</td>
<td><%= text_area :experience, :experience, :required => true %><div class="experience-edit-field-tips">&nbsp;</div></td>
</tr>
<tr>
<!--<tr>-->
<!-- <td class="experience-edit-label">Image:</td>-->
<!-- <td><%= file_field_tag :image, class: "form-control" %>-->
<!--</tr>-->
<!--<tr>-->
<td class="experience-edit-label">Rating:</td>
<td><fieldset class="rating">
<%= radio_button :experience, :rating, "5", :required => true %> <%= label(:experience, :rating.to_s + "_5" ) %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/programs/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<tr>
<td class="program-edit-label"><%= label :program, :region, 'Region' %></td>
<td><%= text_field :program, :region %></td>
</tr>
<tr>
<td class="experience-edit-label">Banner Image:</td>
<td><%= file_field_tag :banner_image, class: "form-control" %>
</tr>
<tr>
<td colspan="2" class="program-edit-submit"><%= submit_tag 'Save' %></td>
Expand Down
4 changes: 4 additions & 0 deletions app/views/programs/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<td class="program-edit-label"><%= label :program, :region, 'Region' %></td>
<td><%= text_field :program, :region, :required => true %></td>
</tr>
<!--<tr>-->
<!-- <td class="experience-edit-label">Banner Image:</td>-->
<!-- <td><%= file_field_tag :banner_image, class: "form-control" %>-->
<!--</tr>-->
<tr>
<td colspan="2" class="program-edit-submit"><%= submit_tag 'Save' %></td>
</tr>
Expand Down
109 changes: 109 additions & 0 deletions setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,113 @@
#!/bin/bash

if [ -z "$C9_HOSTNAME" ]; then
read -p $'\033[1;33mWARNING:This project was designed to run through an Amazon Cloud9 Environment. Some aspects of the development server may not be fully fuctional otherwise. Are you sure you want to continue? [y/N]: \033[0m' answer
answer=${answer,,} # convert the answer to lowercase
if [ "$answer" != "y" ]; then
echo "Exiting."
exit 1
fi
fi

echo -e "\033[32mInstalling Yarn with npm...\033[0m"
npm install -g yarn
if [ $? -eq 0 ]; then
echo -e "\033[32mYarn installed successfully!\033[0m"
else
echo -e "\033[31mFailed to install Yarn.\033[0m"
exit 1
fi

# Load use Ruby 3.1.3 with either RVM or RBENV
if source "$HOME/.rvm/scripts/rvm" ; then
echo -e "\033[32mRVM detected, installing Ruby 3.1.3 with RVM...\033[0m"
if rvm install ruby-3.1.3 ; then
echo -e "\033[32mRuby 3.1.3 installed successfully with RVM!\033[0m"
if rvm use ruby-3.1.3 --default ; then
echo -e "\033[32mUsing Ruby 3.1.3 as the default with RVM.\033[0m"
else
echo -e "\033[31mFailed to set Ruby 3.1.3 as default with RVM.\033[0m"
fi
else
echo -e "\033[31mFailed to install Ruby 3.1.3 with RVM.\033[0m"
fi
else
echo -e "\033[32mRVM not detected, installing Ruby 3.1.3 with rbenv...\033[0m"
if command -v rbenv &>/dev/null ; then
if rbenv install 3.1.3 ; then
echo -e "\033[32mRuby 3.1.3 installed successfully with rbenv!\033[0m"
if rbenv global 3.1.3 ; then
echo -e "\033[32mUsing Ruby 3.1.3 as the global version with rbenv.\033[0m"
else
echo -e "\033[31mFailed to set Ruby 3.1.3 as global version with rbenv.\033[0m"
fi
else
echo -e "\033[31mFailed to install Ruby 3.1.3 with rbenv.\033[0m"
fi
else
echo -e "\033[31mNeither RVM nor rbenv detected. Please install either of them first.\033[0m"
fi
fi


echo -e "\033[32mSetting environment to development...\033[0m"

export RAILS_ENV=development
echo $RAILS_ENV

echo -e "\033[32mInstalling Rails with gem...\033[0m"
gem install rails
if [ $? -eq 0 ]; then
echo -e "\033[32mRails installed successfully!\033[0m"
else
echo -e "\033[31mFailed to install Rails.\033[0m"
exit 1
fi

echo -e "\033[32mInstalling SQLite3 and its dependencies with apt-get...\033[0m"
sudo apt-get install sqlite3 libsqlite3-dev
if [ $? -eq 0 ]; then
echo -e "\033[32mSQLite3 and its dependencies installed successfully!\033[0m"
else
echo -e "\033[31mFailed to install SQLite3 and its dependencies.\033[0m"
exit 1
fi

echo -e "\033[32mInstalling Bundler with gem...\033[0m"
gem install bundler
if [ $? -eq 0 ]; then
echo -e "\033[32mBundler installed successfully!\033[0m"
else
echo -e "\033[31mFailed to install Bundler.\033[0m"
exit 1
fi

echo -e "\033[32mInstalling gems with bundle install...\033[0m"
bundle install
if [ $? -eq 0 ]; then
echo -e "\033[32mGems installed successfully with bundle install!\033[0m"
else
echo -e "\033[31mFailed to install gems with bundle install.\033[0m"
exit 1
fi

echo -e "\033[32mInstalling Yarn packages with yarn install...\033[0m"
yarn install
if [ $? -eq 0 ]; then
echo -e "\033[32mYarn packages installed successfully!\033[0m"
else
echo -e "\033[31mFailed to install Yarn packages.\033[0m"
exit 1
fi

echo -e "\033[32mRunning rails db:migrate...\033[0m"
rails db:migrate
if [ $? -eq 0 ]; then
echo -e "\033[32mRails database migrated successfully!\033[0m"
else
echo -e "\033[31mFailed to migrate Rails database.\033[0m"
exit 1
fi

# Start the Rails server
rails server

0 comments on commit e8f591b

Please sign in to comment.