Skip to content

Commit

Permalink
Fixing syntax for newer rails
Browse files Browse the repository at this point in the history
  • Loading branch information
alaxalves committed Jul 2, 2020
1 parent 5e1a4c1 commit eca187a
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def require_login
login_prompt = "You must be <a href='#{login_link}'>logged in to do this</a>."
format.json { render :json => { :errors => [ login_prompt ] } }
format.html do
render :text => login_prompt # halts request cycle
render html: login_prompt # halts request cycle
end
else
format.html do
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def recent_calibrations
@spectrums = current_user.calibrations.limit(20)
# add the one that's being used in live display:
if params[:calibration_id] && params[:calibration_id] != 'undefined'
new = Spectrum.where(id: params[:calibration_id])
@spectrums = new + @spectrums
new_spectrum = Spectrum.where(id: params[:calibration_id])
@spectrums = new_spectrum + @spectrums
end
@spectrums = @spectrums.uniq
respond_to do |format|
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/likes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ def toggle
@spectrum = Spectrum.find params[:id]
if @spectrum.liked_by(current_user.id)
Like.find_by_user_id(current_user.id,:conditions => {:spectrum_id => @spectrum.id}).delete
render :text => "unliked"
render plain: "unliked"
else
@like = Like.new({
:user_id => current_user.id,
:spectrum_id => params[:id]
})
if @like.save
render :text => @spectrum.likes.length
render html: @spectrum.likes.length
else
render :text => "error"
render plain: "error"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/macros_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def show
format.html {}
format.js {
if params[:run]
render :text => "$W.macro = {"+@macro.code+"};$W.macro.setup()"
render plain: "$W.macro = {"+@macro.code+"};$W.macro.setup()"
else
render :text => "{"+@macro.code+"}"
render plain: "{"+@macro.code+"}"
end
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/match_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def search
format.html { render partial: "macros/spectra", locals: { spectrums: @spectra } if params[:toolPane] }
format.xml { render :xml => @spectra }
format.csv {
render :text => SpectrumsHelper.show_csv(@spectrum)
render html: SpectrumsHelper.show_csv(@spectrum)
}
format.json { render :json => @spectra.map { |s| s.json } } # actually flatten in the json of each spectrum; kind of messy
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def find_match
range = @calibration.wavelength_range
@spectrum.scale_data(range[0],range[1])
@match = Spectrum.find(@set.match(@spectrum))
render :text => "Matched: <a href='/spectra/"+@match.id.to_s+"'>"+@match.title+"</a>"
render plain: "Matched: <a href='/spectra/"+@match.id.to_s+"'>"+@match.title+"</a>"
end

def embed
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/snapshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def show
respond_with(@snapshot) do |format|
format.xml { render :xml => @snapshot }
format.csv {
render :text => SpectrumsHelper.show_csv_snapshot(@snapshot)
render html: SpectrumsHelper.show_csv_snapshot(@snapshot)
}
format.json {
render :json => @snapshot.data
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/spectrums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def show
}
format.xml { render :xml => @spectrum }
format.csv {
render :text => SpectrumsHelper.show_csv(@spectrum)
render html: SpectrumsHelper.show_csv(@spectrum)
}
format.json {
render :json => @spectrum.json
Expand All @@ -121,9 +121,9 @@ def latest_snapshot_id
.select('spectrum_id, created_at, id')
.order("created_at DESC")
.limit(1)
render :text => spectrum.latest_snapshot.id
render html: spectrum.latest_snapshot.id
else
render :text => false
render html: false
end
end

Expand All @@ -139,8 +139,8 @@ def latest
respond_with(@snapshot) do |format|
format.xml { render :xml => @snapshot }
format.csv {
render :text => SpectrumsHelper.show_csv_snapshot(@snapshot) if is_snapshot
render :text => SpectrumsHelper.show_csv(@snapshot) if !is_snapshot
render html: SpectrumsHelper.show_csv_snapshot(@snapshot) if is_snapshot
render html: SpectrumsHelper.show_csv(@snapshot) if !is_snapshot
}
format.json {
render :json => @snapshot.json
Expand Down Expand Up @@ -280,7 +280,7 @@ def create
flash[:notice] = 'Spectrum was successfully created.'
format.html { redirect_to spectrum_path(@spectrum) + calibration_param }
format.xml { render :xml => @spectrum, :status => :created, :location => @spectrum }
format.json { render :text => spectrum_path(@spectrum), :status => :created, :location => @spectrum }
format.json { render html: spectrum_path(@spectrum), :status => :created, :location => @spectrum }
else
render "spectrums/new"
end
Expand Down Expand Up @@ -309,7 +309,7 @@ def create
respond_to do |format|
if request.xhr?
format.json {
render :text => 'Token required for unauthenticated API usage.'
render html: 'Token required for unauthenticated API usage.'
}
else
format.html {
Expand Down Expand Up @@ -344,7 +344,7 @@ def save
params[:tags].to_s.split(',').each do |tag|
@spectrum.tag(tag, current_user.id)
end
render :text => @spectrum.save
render html: @spectrum.save
end

# PUT /spectrums/1
Expand Down Expand Up @@ -469,7 +469,7 @@ def plots_rss

def match
@spectrum = Spectrum.find params[:id]
render :text => @spectrum.find_match_in_set(params[:set]).to_json
render html: @spectrum.find_match_in_set(params[:set]).to_json
end

# Start doing this client side!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def destroy
respond_to do |format|
format.html do
if request.xhr?
render :json => { :message => "success" }
render :json => { message: "success" }
else
flash[:notice] = "Tag '#{@tag.name}' deleted."
redirect_to spectrum_path(@tag.spectrum_id)
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# get 'recent', on: :collection
# end
# end

Expand Down

0 comments on commit eca187a

Please sign in to comment.