I create a class that takes two input parameters from the user, these input parameters are then used to create five others, the problem is that the five others don't show up when I check my validated paramaters only the first ones.
I know that all of the new parameters are added to the params but they don't show up in the model time_delta_params hash when I check what's in it only the first two. Thanks for any help!
My create method for the controller
def create
# XXX Add these columns to the model and populate them
# finalRating, positiveTweets, negativeTweets, neutralTweets, totalTweets
tweetRatings = {:finalRating => 0, :positiveTweets => 0, :negativeTweets => 0, :neutralTweets => 0}
@stock = Stock.find(params[:stock_id])
tweets = getTweets(@stock.hashtag, time_delta_params[:start], time_delta_params[:length].to_i)
tweets.each do |tweet|
case processTweet(tweet)
when 1
tweetRatings[:positiveTweets] += 1
tweetRatings[:finalRating] += 1
when -1
tweetRatings[:negativeTweets] += 1
tweetRatings[:finalRating] -= 1
else
tweetRatings[:neutralTweets] += 1
end
end
params[:final] = tweetRatings[:finalRating]
params[:positive] = tweetRatings[:positiveTweets]
params[:negative] = tweetRatings[:negativeTweets]
params[:neutral] = tweetRatings[:neutralTweets]
params[:total] = tweets.count
# printSomthingToRender(time_delta_params)
@time_delta = @stock.time_deltas.create(time_delta_params)
redirect_to stock_path(@stock)
end
My validation:
def time_delta_params
params.require(:time_delta).permit(
:start,
:length,
:final,
:positive,
:negative,
:neutral,
:total
)
end