Skip to content

bumswerner/fsi

Repository files navigation

README

  1. rvm install ruby-2.4.1

  2. rvm --default ruby-2.4.1

  3. rvm list // check if the correct ruby version selected

  4. gem install rails

  5. gem install bundler

  6. rails new [project-name]

  7. git --version

  8. git config --global user.name = [username]

  9. git config --global user.email = [email]

  10. git config --global --list // shows a list of all settings

  11. git init // initialize a new empty respository

  12. git add -A // include all new or added files to the respository

  13. git status // shows the current respository status

  14. git commit -m "description of commit"

  15. git push // pushed all file to the remote respository

  16. git checkout -f // reset to the last commit
    git reset --hard // stellt die vorherige Version wieder her

  17. GIT <---> Cloud9 cat ~/.ssh/id_rsa.pub // Zeigt den SSH-Key an kopiere den kompletten Schlüssel und füge ihn deinem Github-Accout hinzu Erzeuge ein neues Repository

    …or push an existing repository from the command line: git remote add origin git@github.com:bumswerner/alpha-blog.git // in die Console von C9 eintragen dann zum testen 'git remote -v' eingeben git push -u origin master // pushed den Code zum Repository

  18. Install devise gem 'devise' bundle install --without production rails generate devise:install

    • config/environments/development.rb --> config.action_mailer.default_url_options = { host: 'localhost', port: 8080 }
  19. rails generate devise User if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration. controller/application_controller.rb -> before_action :authenticate_user! rake db:migrate

    skip the user authentication for index action

    skip_before_action :authenticate_user!, only: [:index]

  20. gem 'twitter-bootstrap-rails' bundle install --without production rails generate bootstrap:install static rails g bootstrap:layout application (then hits Y und enter)

  21. gem 'devise-bootstrap-views' bundle install --without production

  22. add this line to file assets/stylesheets/application.css over the line *= require_tree . *= require devise_bootstrap_views

  23. rails g devise:views:locale en rails g devise:views:bootstrap_templates

  24. Use SCSS for stylesheets

    gem 'jquery-rails' gem 'bootstrap-sass', '~> 3.3.5' bundle install --without production assets/javascript/application.js //= require jquery //= require jquery_ujs //= require rails-ujs //= require bootstrap-sprockets //= require turbolinks //= require_tree .

  25. prepare for anynines

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!shit gem install a9s move gem 'sqlite3' to group :development, :test create new group in Gemfile group :production do gem 'pg' ???? gem 'rails_12factor' end bundle install --without production

  1. add to config/application.rb config.assets.initialize_on_precompile = false

  2. install cf cli https://github.com/cloudfoundry/cli/releases/ wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx sudo mv [your-download-dir]/cf /usr/local/bin/cf chmod +x /usr/local/bin/cf

  3. cf api https://api.aws.ie.a9s.eu

  4. cf login --> email and password form anynines account --> 1 for production

  5. You can see the available organizations by tying: cf orgs To see all available spaces cf spaces

  6. You can change or select an organization or a space by typing: cf target -s production cf create-service a9s-postgresql postgresql-single-small [name-of-application] cf service [name-of-application]

  7. add manifest.yml file

    cf push --random-route

    cf run-task [appname] rake db:migrate
    cf logs fsi-htw --recent cf push [appname] -c "bundle exec rake db:migrate"

https://support.anynines.com/hc/en-us/community/posts/234548468-How-to-deploy-your-apps-on-anynines

  1. sudo apt update sudo apt install imagemagick

  2. gem 'letter_opener_web'

how install cli and cf to codeanywhere

curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx sudo mv cf /usr/local/bin sudo curl -o /usr/share/bash-completion/completions/cf https://raw.githubusercontent.com/cloudfoundry/cli/master/ci/installers/completion/cf cf --version cf login API endpoint --> https://api.aws.ie.a9s.eu
cf orgs

cf target -s production cf create-service a9s-postgresql postgresql-single-small [name-of-application] cf service [name-of-application] cf push [name-of-application]

fsi_worker_pgsel --> name of service

new cli for heroku

wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh

for cf

cf ssh [name-of-application] -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails c' ''"

Install RSpec

group :development, :test do

gem 'rspec-rails', '3.5.0'

group :test do gem 'capybara', '2.7.1' end

rails generate rspec:install

bundle binstubs rspec-core

Let's GO -----------------------------------------------------------------------

Process for creatung faculties feature test feature

  • Create a nranch to do the development work
  • Write feature test
  • Build features to make pass one by one
  • Once the feature test passes with no errors - merge branch with master branch

git checkout -b faculty-fecture-spec

rails generate scaffold Faculty name:string symbol:string description:text rake db:migrate rails g bootstrap:themed Faculties


Create a new git topic branch as follows:

git checkout -b adding-guard

Add the following gems to the development group of the Gemfile: gem 'guard', '> 2.14.0' gem 'guard-rspec', '> 4.7.2' gem 'guard-cucumber', '~> 2.1.2'

Run the following command to install the gems: bundle install

Also run the command: guard init

Run the command: bundle binstubs guard

Run: cucumber --init

Make a commit: git add -A git commit -m "Add Guard" git checkout master git merge adding-guard git push


how to delete a branch git branch -d [name-of-branch]

Add FactoryGirl

add gem 'factory_girl_rails' to development, :test group

After running bundle open up the spec/rails_helper.rb file and add the following line inside of the configure block:

spec/rails_helper.rb

config.include FactoryGirl::Syntax::Methods mkdir spec/factories

create new file spec/factories/faculties.rb and add in in the following ode:

FactoryGirl.define do factory :faculty do name "My Amazing Article" symbol "Jon Snow" description "bla bla" end end


Section - Materials



++++ identity ++++ Faculty +++++++++++++++


rails generate scaffold Faculty name:string symbol:string description:text rake db:migrate rails g bootstrap:themed Faculties

class Faculty < ActiveRecord::Base has_many :courses end


++++ identity ++++ Studytype +++++++++++++++


rails generate scaffold Studytype name:string symbol:string description:text rake db:migrate rails g bootstrap:themed Studytypes

class Coursetype < ActiveRecord::Base has_many :courses end


++++ identity ++++ Courseofstudy ++++++++++++++++


rails generate scaffold Courseofstudy name:string symbol:string description:text faculty:references studytype:references rake db:migrate rails g bootstrap:themed Courseofstudies

class Courseofstudy < ActiveRecord::Base belongs_to :studytype belongs_to :faculty has_many :assoziations has_many :categories, :through => :assoziations has_many :lectures, :through => :assoziations end


++++ identity ++++ Category +++++++++++++


rails generate scaffold Category name:string symbol:string description:text rake db:migrate rails g bootstrap:themed Categories

class Category < ActiveRecord::Base has_many :assoziations has_many :lectures, :through => :assoziations has_many :courseofstudies, :through => :assoziations end


++++ identity +++++ Lecture ++++++++++++++


rails generate scaffold Lecture name:string symbol:string description:text rake db:migrate rails g bootstrap:themed Lectures

class Lecture < ActiveRecord::Base has_many :assoziations has_many :categories, :through => :assoziations has_many :courseofstudies, :through => :assoziations has_many :connections has_many :materials, :through => :connections end


++++ identity +++++ Assoziation +++++++++


rails generate scaffold Assoziation code:string instructor:string category:references courseofstudy:references lecture:references rake db:migrate rails g bootstrap:themed Assoziations

class Assoziation < ActiveRecord::Base belongs_to :course belongs_to :category belongs_to :lecture end


++++ identity +++++ Connection +++++++++


rails generate scaffold Connection name:string lecture:references section:references rake db:migrate rails g bootstrap:themed Connections

class Connection < ActiveRecord::Base belongs_to :lecture belongs_to :section end


++++ identity +++++ Section +++++++++


rails generate scaffold Section name:string discription:text rake db:migrate rails g bootstrap:themed Sections

class Section < ActiveRecord::Base has_many :materials has_many :connections has_many :lectures, :through => :connections end


++++ identity +++++ Material +++++++++


rails generate scaffold Material name:string discription:text data:attachment section:references lecture:references rake db:migrate rails g bootstrap:themed Materials

class Material < ActiveRecord::Base belongs_to :section belongs_to :lecture end

change_column(:materials, :id, :bigint)


Section - Benutzer



++++ identity +++++ User +++++++++


Step 1 - Create a Standalone Migration

rails generate migration AddAdminAndModeratorToUsers

Step 2 - Add this to the new migration

add_column :users, :admin, :boolean, :default => false, :null => false add_column :users, :moderator, :boolean, :default => false, :null => false

Step 3 - rake db:migrate


++++ identity +++++ Profile +++++++++


rails generate scaffold Profile nickname:string avatar:attachment user:references rake db:migrate rails g bootstrap:themed Profiles

class Profile < ActiveRecord::Base belongs_to :user end


Section - News



++++ identity +++++ Notification +++++++++


rails generate scaffold Notification title:string message:text image:attachment notificationtype:references rake db:migrate rails g bootstrap:themed Notifications

class Notification < ActiveRecord::Base belongs_to :notificationtype end


++++ identity +++++ Notificationtype +++++++++


rails generate scaffold Notificationtype name:string description:text rake db:migrate rails g bootstrap:themed Notificationtypes

class Notificationtype < ActiveRecord::Base has_many :notifications end


Section - Gallery



++++ identity +++++ Gallery +++++++++


rails generate scaffold Gallery name:string description:text rake db:migrate rails g bootstrap:themed Galleries

class Gallery < ActiveRecord::Base has_many :pictures end


++++ identity +++++ Picture +++++++++


rails generate scaffold Image name:string picture:attachment gallery:references rake db:migrate rails g bootstrap:themed Images

class Picture < ActiveRecord::Base belongs_to :gallery end

Example to change a column

remove_column :images, :user_id, :integer add_column :images, :gallery_id, :integer, references: :gallery add_index :images, :gallery_id

Validation: name, image


Validation Validation


install gem 'petergate', '~> 1.7', '>= 1.7.5'

Prerequisites: Setup Authentication (Devise)

Make sure your user model is defined in app/models/user.rb and called User.

If you're using devise you're in luck, otherwise you'll have to add following methods to your project:

user_signed_in? current_user after_sign_in_path_for(current_user) authenticate_user!

Run the generators

rails g petergate:install rake db:migrate This will add a migration and insert petergate into your User model.

gem install pry

set access roles

access all: [:show, :index], user: {except: [:destroy, :new, :create, :update, :edit]}, moderator: :all, site_admin: :all

Inside your views you can use logged_in?(:admin, :customer, :etc) to show or hide content.

<%= link_to "destroy", destroy_listing_path(listing) if logged_in?(:admin, :customer, :etc) %>

cf ssh -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails c' ''"


ROUTING


Ermöglicht es eine neue Route zu generieren, wenn man test im Browser eingibt, wird der Controller 'galleries' mit der Avtion test aufgerufen.

get 'test', to: :show, controller: 'galleries'


Table 2 --> Studiengang, Symbol, Abschluss, Symbol


index route --> /user/faculties/:faculty_id/courseofstudies show route --> /user/faculties/:faculty_id/courseofstudies/:id


Table 3 --> Studiengang, Symbol, Abschluss, Symbol



create sample data in seed file


rails db:setup


install the gem font-awesome-rails



install the gem kaminari


insert this line into gemfile

gem 'kaminari', '~> 1.0', '>= 1.0.1'

to controller object.page(params[:page]).per(4)

to view <%= paginate @images %>

create a better design rails generate kaminari:views bootstrap4


install the gem Lightbox for Bootstrap 4


insert this line into gem file gem 'lightbox-bootstrap-rails', '5.1.0.1'

in assets/javascripts/application.js //= require lightbox-bootstrap

in assets/javascripts/application.js *= require lightbox-bootstrap

assets/javascripts/lightbox_bootstraped.coffee

$(document).delegate '*[data-toggle="lightbox"]', 'click', (event) -&gt; event.preventDefault() $(this).ekkoLightbox() return

website for pictures

https://unsplash.it/

rake assets:precompile !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

get connection to rails console cf ssh fsi -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails c' ''"

cf run-task fsi 'rails db:setup'


Design


colors:

#eff2f7 #f4f6f9

select_date(new.updated_at, order: [:year, :month, :day])

htw saar | Facebook
<%= fa_icon "facebook" %>
      $ heroku pg:reset DATABASE

About

Fachschaft Informatik

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published