Friday, January 20, 2017

Calculation Server Architecture | Fixed issues

Newest questions tagged ruby-on-rails - Stack Overflow

Calculation Server Architecture | Fixed issues


Calculation Server Architecture

Posted: 20 Jan 2017 07:10 AM PST

I have a rails app. This app takes parameters from the users and sends it to what I think would be called a slave application server that runs heavy calculations in Python. This slave server is located on the same physical box and runs a Python "SimpleHTTPServer" (just a basic web server).

I set up the slave to receive commands through post requests and run the calculations. Is it appropriate for the python server to receive these requests through GET/POST even though it is on the same box or should I be using another protocol?

**note I have looked into rubypython and other direct connectors but I need a separate app server to run calculations.

Rails with Webpack

Posted: 20 Jan 2017 06:58 AM PST

I am using ReactOnRails app and I have node-modules folder with packages installed using npm. How can I make these javascript libaries available in app/assets/javascript/application.js, so I do not have to for example install jquery in my modules and in my Gemfile?

This is my webpack config file:

/* eslint comma-dangle: ["error",    {"functions": "never", "arrays": "only-multiline", "objects":  "only-multiline"} ] */    const webpack = require('webpack');  const path = require('path');    const devBuild = process.env.NODE_ENV !== 'production';  const nodeEnv = devBuild ? 'development' : 'production';    const config = {    entry: [      'es5-shim/es5-shim',      'es5-shim/es5-sham',      'babel-polyfill',      './app/bundles/Home/startup/registration',    ],      output: {      filename: 'webpack-bundle.js',      path: '../app/assets/webpack',    },      resolve: {      extensions: ['', '.js', '.jsx'],      alias: {        react: path.resolve('./node_modules/react'),        'react-dom': path.resolve('./node_modules/react-dom'),      },    },    plugins: [      new webpack.DefinePlugin({        'process.env': {          NODE_ENV: JSON.stringify(nodeEnv),        },      }),    ],    module: {      loaders: [        {          test: require.resolve('react'),          loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham',        },        {          test: /\.jsx?$/,          loader: 'babel-loader',          exclude: /node_modules/,        },      ],    },  };    module.exports = config;    if (devBuild) {    console.log('Webpack dev build for Rails'); // eslint-disable-line no-console    module.exports.devtool = 'eval-source-map';  } else {    config.plugins.push(      new webpack.optimize.DedupePlugin()    );    console.log('Webpack production build for Rails'); // eslint-disable-line no-console  }  

Rails form_for route module undefined method

Posted: 20 Jan 2017 07:32 AM PST

I'm having a issue with scopes. I've defined

# routes.rb  resources :asientos, module:'asientos'    # app/models/asientos/asiento.rb  module Asientos    class Asiento < ActiveRecord:Base    end  end      # app/controllers/asientos/asientos_controller.rb  module Asientos    class AsientosController < ApplicationController      def new        @asiento = Asientos::Asiento.new      end    end  end    # app/views/asientos/asientos/new  <%= form_for(@asiento) do |f| %>  ...  

rake routes

      asientos GET      /asientos(.:format)                                       asientos/asientos#index                 POST     /asientos(.:format)                                       asientos/asientos#create     new_asiento GET      /asientos/new(.:format)                                   asientos/asientos#new    edit_asiento GET      /asientos/:id/edit(.:format)                              asientos/asientos#edit         asiento GET      /asientos/:id(.:format)                                   asientos/asientos#show                 PATCH    /asientos/:id(.:format)                                   asientos/asientos#update                 PUT      /asientos/:id(.:format)                                   asientos/asientos#update                 DELETE   /asientos/:id(.:format)                                   asientos/asientos#destroy  

Now whenever the form tries to render, i get

undefined method `asientos_asiento_index_path' for #<#<Class:0x000000065b3b40>:0x00000006ba5f30>  

I've seen some of the answers like

form_for and scopes, rails 3

Module route in Rails with form_for(@object)

But none of them present a clear solution, o suggest some kind of patching.

Furthermore, form_for now generates asientos_ prefix, and in my controller now i have to rename also params.require(:asientos) to params.require(:asientos_asientos) ... not pretty...

Any suggestions (besides undoing namespacing) would be much appreciated. Thanks in advance.

Why does my rails not run?

Posted: 20 Jan 2017 07:14 AM PST

When I run $ rails -server to start a server, there comes an error:

Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile or available on this machine.

Does that mean I did not install sqlite3? How can I resolve the issue?

Rails, Devise, Capybara, current_user not working properly in create action during test

Posted: 20 Jan 2017 07:12 AM PST

A user can edit his own content, if a condition is reached. Here is the condition:

ng-show="argumentation.user_id == userid"  

Everything works as expected, when I visit my page with rails s, however during the test, argumentation.user_id returns nothing.

Here is my code

When the user presses a button, the create-action gets called:

  def create      @argumentation = Argumentation.create!(          title: "Labore et Dolore",          content: "Errare humanum est",          user_id: current_user.id #<-- Not working during the test.      )    end  

Here is one of my test:

   visit "/argumentation#!/overview"      click_button "Argumentation erstellen"        fill_in "argumentation_title", with: "A Defence of Moral Realism"      fill_in "argumentation_content", with: "Russ Shafer-Landau"        click_button "Speichern"      save_screenshot('screen.png', full: true)      click_button "Übersicht" #<-- In test, this button is not there, but should be  

I made a screenshot, which shows some further information: It shows the ID of the current user and the Owner-ID of the content. You see both at the top of the image. Outside of the test, the argumentation id is filled with the correct information. enter image description here

Here is how the current user is retrieved:

In an angular-controller:

$http.get("/getcurrentuser.json").then(function(data,status,headers,config) {          $scope.userid = data.data;     });  

In rails-controller:

  def get_current_user      @id = 0      if current_user        @id = current_user.id      end      respond_to do |format|        format.json { render json: @id}      end    end  

I researched on this issue and some mentioned, that capybara and poltergeist js have sometimes difficulties with the current_user feature of devise. I tried to follow this guide from devise and changed my configuration (you can see it below).

I think, one issue may be, that I added this bit of code at the wrong place. I added it below to spec/rails_helper.rb. The guide does not say, where exactly it has to be added.

class ActiveRecord::Base    mattr_accessor :shared_connection    @@shared_connection = nil      def self.connection      @@shared_connection || retrieve_connection    end  end    # Forces all threads to share the same connection. This works on  # Capybara because it starts the web server in a thread.  ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection  

spec/rails_helper.rb

# This file is copied to spec/ when you run 'rails generate rspec:install'  ENV['RAILS_ENV'] ||= 'test'  require File.expand_path('../../config/environment', __FILE__)  # Prevent database truncation if the environment is production  abort("The Rails environment is running in production mode!") if Rails.env.production?  require 'spec_helper'  require 'rspec/rails'  require 'devise'  require 'capybara/poltergeist'  Capybara.javascript_driver = :poltergeist  Capybara.default_driver = :poltergeist  # Add additional requires below this line. Rails is not loaded until this point!    # Requires supporting ruby files with custom matchers and macros, etc, in  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are  # run as spec files by default. This means that files in spec/support that end  # in _spec.rb will both be required and run as specs, causing the specs to be  # run twice. It is recommended that you do not name files matching this glob to  # end with _spec.rb. You can configure this pattern with the --pattern  # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.  #  # The following line is provided for convenience purposes. It has the downside  # of increasing the boot-up time by auto-requiring all files in the support  # directory. Alternatively, in the individual `*_spec.rb` files, manually  # require only the support files necessary.  #  # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }    # Checks for pending migration and applies them before tests are run.  # If you are not using ActiveRecord, you can remove this line.  ActiveRecord::Migration.maintain_test_schema!    RSpec.configure do |config|    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures    config.fixture_path = "#{::Rails.root}/spec/fixtures"    config.include Devise::Test::ControllerHelpers, type: :controller    config.include Warden::Test::Helpers    # If you're not using ActiveRecord, or you'd prefer not to run each of your    # examples within a transaction, remove the following line or assign false    # instead of true.    config.use_transactional_fixtures = false      # RSpec Rails can automatically mix in different behaviours to your tests    # based on their file location, for example enabling you to call `get` and    # `post` in specs under `spec/controllers`.    #    # You can disable this behaviour by removing the line below, and instead    # explicitly tag your specs with their type, e.g.:    #    #     RSpec.describe UsersController, :type => :controller do    #       # ...    #     end    #    # The different available types are documented in the features, such as in    # https://relishapp.com/rspec/rspec-rails/docs    config.infer_spec_type_from_file_location!      # Filter lines from Rails gems in backtraces.    config.filter_rails_from_backtrace!    # arbitrary gems may also be filtered via:    # config.filter_gems_from_backtrace("gem name")    config.before(:suite) do      DatabaseCleaner.clean_with(:truncation)    end      config.before(:each) do      DatabaseCleaner.strategy = :transaction    end      config.before(:each, :type => :feature) do      DatabaseCleaner.strategy = :truncation    end    config.before(:each) do      DatabaseCleaner.start    end    config.after(:each) do      DatabaseCleaner.clean    end  end    class ActiveRecord::Base    mattr_accessor :shared_connection    @@shared_connection = nil      def self.connection      @@shared_connection || retrieve_connection    end  end    # Forces all threads to share the same connection. This works on  # Capybara because it starts the web server in a thread.  ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection  

Login in test:

  let(:email) { "bob@example.com" }    let(:password) { "password123" }      before do      @user = User.create!(email: email,               password: password,                password_confirmation: password)    end      login_as(@user, :scope => :user)  

Can someone spot the error?

Destroy nested resources from a join table

Posted: 20 Jan 2017 06:30 AM PST

I have the following case where I need to destroy material objects associated to item_materials coming from project

begin    require 'bundler/inline'  rescue LoadError => e    $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'    raise e  end    gemfile(true) do    source 'https://rubygems.org'    gem 'rails', '4.2.7.1'    gem 'sqlite3'  end    require 'active_record'  require 'minitest/autorun'  require 'logger'    Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)    ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')  ActiveRecord::Base.logger = Logger.new(STDOUT)    ActiveRecord::Schema.define do    create_table :projects, force: true do |t|    end      create_table :items, force: true do |t|      t.integer :project_id    end      create_table :materials, force: true do |t|    end      create_table :item_materials, force: true do |t|      t.integer :item_id      t.integer :material_id    end  end    class Project < ActiveRecord::Base    has_many :items, inverse_of: :project      accepts_nested_attributes_for :items, allow_destroy: true      def clean_up_items      items.each do |item|        item.item_materials.each do |item_material|          item_material.mark_for_destruction          item_material.material.mark_for_destruction        end      end        save    end  end    class Item < ActiveRecord::Base    belongs_to :project, inverse_of: :items    has_many :item_materials, dependent: :destroy, inverse_of: :item      accepts_nested_attributes_for :item_materials, allow_destroy: true  end    class ItemMaterial < ActiveRecord::Base    belongs_to :item, inverse_of: :item_materials    belongs_to :material, inverse_of: :item_materials      accepts_nested_attributes_for :material, allow_destroy: true  end    class Material < ActiveRecord::Base    has_many :item_materials, dependent: :destroy, inverse_of: :material  end    class ProjectTest < Minitest::Test    def test_destroy_item_material_and_material      project = Project.create!      item = Item.create! project: project      material = Material.create!      item_material = ItemMaterial.create! item: item, material: material        assert project.reload.clean_up_items        assert Project.find_by_id(project)      assert Item.find_by_id(item)      assert_nil ItemMaterial.find_by_id(item_material)      assert_nil Material.find_by_id(material)    end  end  

Is there a way to accomplish that without manually open a transaction, just setting the right association options?

Gem for enumerating an IP range? [duplicate]

Posted: 20 Jan 2017 06:22 AM PST

This question already has an answer here:

I'm looking for a Gem that can take in start IP and an end IP address and give me the IPs in the middle.

I've seen 'ipaddress-gem' but this takes an IP and a netmask when you want a range, I want something that gives me IPs between 2 arbitrary IPs. For example give me all the IPs between 127.0.0.1 and 127.0.1.23 for example.

Does anything like this actually exist?

Embed Public EventBrite Events near me

Posted: 20 Jan 2017 06:04 AM PST

Is there a way for me to show Public "events in your area" on my web app using Eventbrite's API without an authenticity token?

Gmail in browser and rails html emails [on hold]

Posted: 20 Jan 2017 05:54 AM PST

I have an issue with rails html email into gmail browser: it does not show it but just show 'Message clipped'. In the Mail desctop client email is shown normally with images, styles, etc. Into yandex, mail.ru also no problem.

Do you have any ideas how to show html emails into gmail browser?

Selenium slow click action only localhost

Posted: 20 Jan 2017 05:33 AM PST

I am running selenium locally, but it is extremely slow on find and click.

test_helper.rb

Capybara.register_driver :selenium do |app|      Capybara::Selenium::Driver.new(app, browser: :chrome)  end  

This is a test on my page:

feature "dashboard" do    include Warden::Test::Helpers    scenario "test1", :js => true  do      visit root_path      visit new_user_session_path       #any of this are super slow      #find("a[href='#{/users/sign_up}']").click      #page.find(:css, 'a[href="/users/passsword/new"]').click      #page.find(:xpath, "//a[@href='/users/sign_up']").click     end   

However, the visit action is almost instantly.

I've tried another test:

feature "dashboard" do    include Warden::Test::Helpers    scenario "test1", :js => true  do      visit 'http://www.google.com.uy'      page.find(:xpath, "//a[@href='//www.google.com.uy/intl/es-419/about.html?fg=1']").click     end   

And it worked.

How can I find the cause on my site? The new_user_session_path is devise's default template and controller.

how to test partial with instance variables

Posted: 20 Jan 2017 06:20 AM PST

so i need to test a partial. the partial is rendered by specific action, its something like messages box in facebook. my test looks like this:

describe 'partials/_partial.js.erb' do    it 'displays stuff' do      render    end  end  

i run it, and i know it does what i want because i immediately get

Failure/Error: if @items.count > 0         ActionView::Template::Error:         undefined method `count' for nil:NilClass  

i do not need to hear that it is a bad practice to use instance vars in a partial, it is already there and i need to work with it. so how do i set @items here...?

UPDATE:

controller action looks like this:

def controller_method      @items = items_method      render_version(:partial => "partials/_partial.js.erb")  end  

Loading modal while page is loading and close after done loading

Posted: 20 Jan 2017 05:35 AM PST

I there a way to load a modal while page is loading and close it when it is done loading?

For example, when I click a link:

<a href="localhost:3000/users">Stackoverflow</a>  

the browser will load and at the same time modal will open. And if browser done loading the modal will close as well.

How can I possibly do it?

Ruby overriding method from Trie gem - undefined method

Posted: 20 Jan 2017 07:11 AM PST

I use Trie (https://github.com/tyler/trie) gem in project and love it. But it has one issue that is really anoying.

has_key? method returns nil when key is not found instead of false (as every method ending with ? should)

I've tried opening an issue on their GitHub (https://github.com/tyler/trie/issues/26) but no luck.

So, reasonable next step - try to override the method.

I added this to my project:

class Trie      alias :old_has_key? :has_key?      def has_key?(key)          puts "My new Trie has_key"          old_has_key?(key)      end  end  

Just to see if I can get away with it.

Unfortunately, when I run rails console I get:

`<class:Trie>': undefined method `has_key?' for class `Trie' (NameError)  

As I found elsewhere, this should work. Any idea why it doesn't?

What I'm missing here? Location of trie.rb? Something else?

How to put Java Script variable in Erb method? [on hold]

Posted: 20 Jan 2017 06:02 AM PST

i have set onclick event on button through which i am calling a function otp(email.value) and passing input field email. On scripting side i want to put this email value in erb method.But i didnt found any method to do that.
please help me .

my code is
enter image description here

Where is in VERTX $VERTX_HOME/conf/langs.properties config location?

Posted: 20 Jan 2017 05:02 AM PST

I can not find where to place language properties config with VERTX I want to run Rack with Vertx (for rails):

here https://github.com/isaiah/jubilee/wiki/Running-as-vertx-module

it suggests to add this line:

rackup=isaiah~mod-rack~0.1.1:org.jruby.jubilee.JubileeVerticleFactory .ru=rackup  

into the the configuration file:

$VERTX_HOME/conf/langs.properties  

But i can't find it...

recommendation engine in ruby on rails

Posted: 20 Jan 2017 05:05 AM PST

I would like to have a recommendation functionality for my Rails web-app. In particular, I want to recommend a profile to other users.

Is there an engine/gem for this purpose in Rails? If not, where should I start to build it? can I use python Or Machine learning and how?

Thank you.

Rails and Docker for large web apps [on hold]

Posted: 20 Jan 2017 04:33 AM PST

I'm currently working on a Rails webapp, never been in production, it would give to the users some geolocated information, so a large number of request per seconds..

I recently discovered that Rails app can runs into Docker. What are the main benefits? Is really important for a large scale application to be into docker (maybe with different coding architecture) or is enough to buy a powerful cloud computing service like AWS and use it?

I know a really few features of docker by University Lectures of some previous courses.

Is important to understand in order to change (maybe) the app architecture if necessary or choose the right (future) computing service. Thank you.

Capistrano - Net::SSH::AuthenticationFailed

Posted: 20 Jan 2017 04:21 AM PST

I can't figure out how to solve this problem. Capistrano didn't work correctly. So can't deploy my app. Here's the error.

$ bundle exec cap staging deploy  (Backtrace restricted to imported tasks)  cap aborted!  Net::SSH::AuthenticationFailed: Authentication failed for user ec2-user@13.112.91.105  

Here's config file, named config/deploy.rb

# config valid only for Capistrano 3.1  lock '3.5.0'    set :application, 'dola'  set :repo_url, 'git@ghe.intelligence-dev.com/inolab/eiicon-dola.git'    # Default branch is :master  # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call  set :branch, 'master'    # Default deploy_to directory is /var/www/my_app  set :deploy_to, '/var/www/dola'    # Default value for keep_releases is 5  # set :keep_releases, 5    set :rbenv_type, :user  set :rbenv_ruby, '2.3.2-p217'  set :rbenv_map_bins, %w{rake gem bundle ruby rails}  set :rbenv_roles, :all  set :linked_dirs, %w{bin log tmp/backup tmp/pids tmp/cache tmp/sockets vendor/bundle}  role :web, %w{13.112.91.105}    namespace :deploy do      desc 'Restart application'    task :restart do      on roles(:app), in: :sequence, wait: 5 do        # Your restart mechanism here, for example:        # execute :touch, release_path.join('tmp/restart.txt')      end    end      after :publishing, :restart      after :restart, :clear_cache do      on roles(:web), in: :groups, limit: 3, wait: 10 do        # Here we can do anything such as:        # within release_path do        #   execute :rake, 'cache:clear'        # end      end    end    end  

And here's config/deploy/staging.rb

 Simple Role Syntax  # ==================  # Supports bulk-adding hosts to roles, the primary server in each group  # is considered to be the first unless any hosts have the primary  # property set.  Don't declare `role :all`, it's a meta role.    role :app, %w{ec2-user@13.112.91.105}  role :web, %w{ec2-user@13.112.91.105}    # Extended Server Syntax  # ======================  # This can be used to drop a more detailed server definition into the  # server list. The second argument is a, or duck-types, Hash and is  # used to set extended properties on the server.  server '13.112.91.105', user: 'ec2-user', roles: %w{web app}, my_property: :my_value    # Custom SSH Options  # ==================  set :stage, :staging  set :rails_env, 'staging'  server '13.112.91.105', user: 'ec2-user',  roles: %w{web app}   set :ssh_options, {     keys: [File.expand_path('~/.ssh/id_rsa_ec2.pem)')]  }  

Anyone, please!

How to implement a check box in the index page

Posted: 20 Jan 2017 03:47 AM PST

I have a index page that lists all the homes.I have a Boolean field called active for the homes.We want have a check box on the index page so that a user can check the homes he want to activate.How can this be done??

    <div style="margin-top:25px; margin-bottom:150px;">         <div class="container">         <div class="row">            <div class="col-md-2">              <ul class="sidebar-list">                  <li class="sidebar-item"><%= link_to "Homes", homes_path, class:"sidebar-link active"%></li>                  </ul>          </div>          <div class="col-md-10">              <div class="panel panel-default">                  <div class="panel-heading" style="background-color:#6dae4e;">                      Homes(<%= @homes.length %>)                  </div>                  <div class="panel-body">                          <% @homes.each do |home| %>                          <div class="row">                              <div class="col-md-2">                                  <%= image_tag home.home_photos[0].image.url if home.home_photos.length > 0 %>                              </div>                              <div class="col-md-2">                                  <h4><%= link_to home.name, home %></h4>                              </div>                              <div class="col-md-3 right">                                  <%= link_to "Edit", edit_home_path(home), class: "btn btn-green"%>                              </div>                          </div>                          <hr/>                      <% end %>                  </div>              </div>          </div>        </div>  </div>  

error in start a server in ruby on rails

Posted: 20 Jan 2017 03:30 AM PST

when i want to start rails local server an error come :

DL is deprecated, please use Fiddle  Expected string default value for '--rc'; got false (boolean)    create    create  README.rdoc    create  Rakefile    create  config.ru    create  .gitignore    create  Gemfile    create  app    create  app/assets/javascripts/application.js    create  app/assets/stylesheets/application.css    create  app/controllers/application_controller.rb    create  app/helpers/application_helper.rb    create  app/views/layouts/application.html.erb    create  app/assets/images/.keep    create  app/mailers/.keep    create  app/models/.keep    create  app/controllers/concerns/.keep    create  app/models/concerns/.keep    create  bin    create  bin/bundle    create  bin/rails    create  bin/rake    create  config    create  config/routes.rb    create  config/application.rb    create  config/environment.rb    create  config/environments    create  config/environments/development.rb    create  config/environments/production.rb    create  config/environments/test.rb    create  config/initializers    create  config/initializers/backtrace_silencers.rb    create  config/initializers/filter_parameter_logging.rb    create  config/initializers/inflections.rb    create  config/initializers/mime_types.rb    create  config/initializers/secret_token.rb    create  config/initializers/session_store.rb    create  config/initializers/wrap_parameters.rb    create  config/locales    create  config/locales/en.yml    create  config/boot.rb    create  config/database.yml    create  db    create  db/seeds.rb    create  lib    create  lib/tasks    create  lib/tasks/.keep    create  lib/assets    create  lib/assets/.keep    create  log    create  log/.keep    create  public    create  public/404.html    create  public/422.html    create  public/500.html    create  public/favicon.ico    create  public/robots.txt    create  test/fixtures    create  test/fixtures/.keep    create  test/controllers    create  test/controllers/.keep    create  test/mailers    create  test/mailers/.keep    create  test/models    create  test/models/.keep    create  test/helpers    create  test/helpers/.keep    create  test/integration    create  test/integration/.keep    create  test/test_helper.rb    create  tmp/cache    create  tmp/cache/assets    create  vendor/assets/javascripts    create  vendor/assets/javascripts/.keep    create  vendor/assets/stylesheets    create  vendor/assets/stylesheets/.keep       run  bundle install    DL is deprecated, please use Fiddle  

after a few min an error come and say to install json gem and when i want install json gem an error come.what can i do to run server . ( my rails version :2.0.0 ruby version:2.0.0 )

Couldn't find ProjectSession with 'id'=

Posted: 20 Jan 2017 05:53 AM PST

Here i have a project to which i am adding a session and for a project session i am trying to add task. i am able to create project and add project session for project but when i am trying to add task for session using project_sessions_id i am getting error Couldn't find ProjectSession with 'id'= and 'app/controllers/tasks_controller.rb:60:in set_project_session i am able to get the project session id also project_sessions/11 in the url but when i click 'create task' i am getting this error. how can i resolve this?

here's what i have done

ProjectSessionController:

class ProjectSessionsController < ApplicationController    before_action :set_project_session, only: [:show, :edit, :update, :destroy]    before_action :authenticate_user!    before_action :set_project      def index      @project_sessions = ProjectSession.all    end      def show      @project_sessions = ProjectSession.where(project_id: @project.id).order("created_at DESC")    end      def new      @project_session = ProjectSession.new    end      def edit    end      def create      @project_session = ProjectSession.new(project_session_params)      @project_session.project_id = @project.id        #respond_to do |format|        if @project_session.save          redirect_to @project          #format.html { redirect_to @project_session, notice: 'Project session was successfully created.' }          #format.json { render :show, status: :created, location: @project_session }        else          format.html { render :new }          format.json { render json: @project_session.errors, status: :unprocessable_entity }        end      

No comments:

Post a Comment