while filling new form this error is came. undefined method `created_by' for nil:NilClass
@user_data = UserInfo.get_user_data(@f_user_new.created_by).first
while filling new form this error is came. undefined method `created_by' for nil:NilClass
@user_data = UserInfo.get_user_data(@f_user_new.created_by).first
**I am using ruby 1.9.3 it would be helpful if i can get any gem name or method to convert the .ppt to .mp4
I am trying to cover these exceptions raised by Octokit when something undesired happens. These are some of the scenarios that needs to be covered in my spec, however I am not getting any relevant tests to refer for this: Octokit::AbuseDetected
Octokit::UnprocessableEntity
Octokit::TooManyRequests
Also I am finding no related resources for the same. This is the file that has these.
# frozen_string_literal: true
require 'asset_ingester/helpers/logging'
require 'asset_ingester/helpers/poller'
require 'octokit'
require 'colorize'
module AssetIngester
module SCM
class GithubScm
include AssetIngester::Helpers::Logging
API_ENDPOINT = 'https://github.cerner.com/api/v3/'
RESULTS_PER_PAGE = 100
DEFAULT_WAIT = 60
MAX_RETRY_ATTEMPTS = 5
def initialize
@client = Octokit::Client.new(access_token: ENV['GIT_ACCESS_TOKEN'], api_endpoint: API_ENDPOINT)
end
def search_code(search_terms)
search_results = []
search_terms.each do |search_term|
retry_on_abuse do
response = @client.search_code(search_term, per_page: RESULTS_PER_PAGE)
logger.info "Found '#{search_term}' code search results: #{response[:total_count]}"
search_results.concat(response[:items])
last_response = @client.last_response
retry_on_abuse do
while last_response.rels[:next]
last_response = last_response.rels[:next].get(query: {per_page: RESULTS_PER_PAGE})
search_results.concat(last_response.data[:items])
end
end
end
end
search_results
end
def all_organizations
logger.info 'Searching all organizations...'
search_results = []
retry_on_abuse do
response = @client.all_organizations
search_results.concat(response)
last_response = @client.last_response
retry_on_abuse do
while last_response.rels[:next]
last_response = last_response.rels[:next].get(query: {})
search_results.concat(last_response.data)
end
end
end
search_results
end
def search_repos(search_term)
search_results = []
retry_on_abuse do
response = @client.search_repositories(search_term, per_page: RESULTS_PER_PAGE)
logger.info "Found '#{search_term}' repository search results: #{response[:total_count]}"
search_results.concat(response[:items])
last_response = @client.last_response
retry_on_abuse do
while last_response.rels[:next]
last_response = last_response.rels[:next].get(query: {per_page: RESULTS_PER_PAGE})
search_results.concat(last_response.data[:items])
end
end
end
search_results
end
private
def retry_on_abuse
retry_template = 'Retrying after %d seconds. Response status: %s'
Helpers::Poller.poll(DEFAULT_WAIT, MAX_RETRY_ATTEMPTS) do
yield
rescue Octokit::AbuseDetected => e
logger.warn "Abuse detected. #{format(retry_template, DEFAULT_WAIT, e.response_headers[:status])}"
:re_poll
rescue Octokit::UnprocessableEntity => e
logger.warn "Insufficient permissions. Response status: #{e.response_headers[:status]}"
rescue Octokit::TooManyRequests => e
logger.warn "API Request Limit Reached. #{format(retry_template, DEFAULT_WAIT, e.response_headers[:status])}"
:re_poll
end
end
end
end
end
The method retry_on_abuse handles these scenarios. How do I write specs for these?
I have a haml file to generate the proposal submit page, the code is like this:
.row
%fieldset.col-md-6
=proposal.title_input(form)
=proposal.description_input(form)
%fieldset.col-md-6
.row
.col-md-3
= form.label t('.choose_tags'), { class: 'tags-label' }
.col-md-6.form-spacing
= form.hidden_field :tags, { class: 'proposal-tags' }
#tags-container.tags-container
.row
.form-submit.clearfix
.pull-left
= submit_proposal_button(proposal)
It generates a proposal submitting page which allowed the user to edit the title and description of their proposal, and the proposal's tag as well. There's a submit button on the bottom to save it.
And I want to add another input box which allowed the user to update their self-introduction as well. So, I simply added it to this file:
.row
%fieldset.col-md-6
=proposal.title_input(form)
=proposal.description_input(form)
%fieldset.col-md-6
.row
.col-md-3
= form.label t('.choose_tags'), { class: 'tags-label' }
.col-md-6.form-spacing
= form.hidden_field :tags, { class: 'proposal-tags' }
#tags-container.tags-container
// ----- the following content is what I added.-----
%fieldset.col-md-6
= simple_form_for user, url: person_path(id: user.id), html: {role: 'form'} do |f|
%h4= I18n.t('.your_profile')
.form-group
= f.input :bio, class: 'form-control', placeholder: I18n.t('.bio'),
input_html: {rows: 7}, maxlength: 1500
// ----- the above content is what I added.-----
.row
.form-submit.clearfix
.pull-left
= submit_proposal_button(proposal)
After I added it, the submit button couldn't work. Whenever I click on it, nothing happens. I'm a beginner of haml and rails, and I'm confusing about it. Any help is appreciated!
The code of submit_proposal_button is:
def submit_proposal_button (proposal)
capture_haml do
haml_tag :button,
type: 'submit',
name: 'submit',
value: proposal.id,
class: 'btn btn-primary' do
haml_concat(t('.form.submit'))
end
end
end
The following code that is inserting new rows correctly if people isn't found. If people is found I want it to update existing row and also the import_id but the update isn't working. So basically if a new import contains the same data in people I want to just update import_id. people has name age.
Person.transaction do
people.flatten.each do |people|
Person.create_with({ import_id: import.id, **people }).find_or_create_by(**people)
end
end
Below is my package.json.When i run npm run rails--server.I see the errorno such file or directory webpack-manifest.json.My package.json.Please help me know where I am going wrong.
{
"name": "logging_response_engine-client",
"private": true,
"browserslist": [
"extends browserslist-config-terra"
],
"scripts": {
"build:test": "webpack --config node_modules/orion-toolkit-js/lib/conf/react-on-rails/webpack/engine/webpack.config.js -p",
"build:production": "NODE_ENV=production webpack --config node_modules/orion-toolkit-js/lib/conf/react-on-rails/webpack/engine/webpack.config.js -p",
"build:development": "webpack --config node_modules/orion-toolkit-js/lib/conf/react-on-rails/webpack/engine/webpack.config.js"
},
"entryPointDependencies": [
"logging-response-component"
],
"dependencies": {
"logging-response-component": "git://github.cerner.com/GS077478/logging-response- component.git#master",
"orion-application": "^1.1.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"babel-loader": "^6.3.2",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-regenerator": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"browserslist-config-terra": "^1.0.0",
"core-js": "^3.1.3",
"raf": "^3.4.1",
"orion-toolkit-js": "^4.0.0",
"react": "^16.8.5",
"react-dom": "^16.8.5",
"react-intl": "^2.4.0",
"react-on-rails": "7.0.4",
"regenerator-runtime": "^0.13.2",
"terra-toolkit": "^5.0.1",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.3.1",
"orion-webpack-plugins": "^1.0.0",
"webpack-manifest-plugin": "^2.2.0"
}
}
what is the idea behind creating a new instance of the method inside class << self construct? I understand methods are put under class << self block to make it class methods but what it means to creating a new instance of the method itself?
class foo
class << self
def bar(param)
new.bar(some_param)
end
end
end