Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can anyone know the meaning for the following symbol in rails?

=>

JavaScript
def update
  account = Account.find params[:id]
  permitted = params.require(:account).permit(:name, :otherparam)
  account.update_attributes permitted
  render :json => account
end


for what purpose we need to use the above expression?

I have searched it in google. but no luck.


Thanks in advance
Posted
Updated 19-Oct-15 20:16pm
v3
Comments
Palash Mondal_ 20-Oct-15 1:16am    
where did you got the above code? doesn't look like a jQuery code?
Amit Jadli 20-Oct-15 1:40am    
I think this is Ruby on Rails code..not jquery or javascript code..
priya dharshan 20-Oct-15 2:17am    
sry. its actually rail snippet
Krunal Rohit 20-Oct-15 2:47am    
I think you're account info would be rendered in json.

-KR

It is called a Hash Rocket. Used for creating hashes like this {key1 => value1, key2 => value2}
By the way, new style syntax (Ruby 1.9) is: {key1: value1, key2: value2}

Good luck!
 
Share this answer
 
v2
This is called Arrow functions.

An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value. Arrow functions are always anonymous.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions[^]

This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900